I have entity and rest controller, when I make a request to my controller it throws this exception:
java.lang.IllegalArgumentException: Parameter value [1] did not match expected type [java.lang.Integer (n/a)]
My controller:
@GetMapping("/createCharacter")
public Character createCharacters(@RequestParam("userId") Integer userId, @RequestParam("mapId") long mapId) {
return createCharactersService.createCharacters(userId, mapId);
}
My entity has int type id:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
Since the Id is a uuid you must keep it as a string in the entity.
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private String id;
Therefore you are bound to use it as a String in Service and in Controller.
@GetMapping("/createCharacter")
public Character createCharacters(@RequestParam("userId") String userId, @RequestParam("mapId") long mapId) {
return createCharactersService.createCharacters(userId, mapId);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments