Parameter value [1] did not match expected type [java.lang.Integer (n/a)]

gg ff :

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;
Christos Karapapas :

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.

edited at
0

Comments

0 comments
Login to comment

Related

InvalidDataAccessApiUsageException: Parameter value [...] did not match expected type [java.util.UUID (n/a)]

@Value -> Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'

Hibernate Parameter value [568903] did not match expected type [java.lang.Long]

nested exception is java.lang.IllegalArgumentException: Parameter value [2020-04-20] did not match expected type [java.util.Date (n/a)]]

Parameter value did not match expected type

Parameter value [0] did not match expected type [java.lang.Integer]

IllegalArgumentException: You have attempted to set a value of type java.lang.String for parameter markup with expected type of java.math.BigDecimal

InvalidDataAccessApiUsageException: Parameter value element did not match expected type

Parameter value [2018-04-08T11:02:44] did not match expected type [java.util.Date (n/a)]

The type of parameter “registrationId” is expected as “integer”, not “java.lang.Long”

Parameter value [100] did not match expected type [java.time.LocalDateTime (n/a)]

(SOLVED) value of type java.lang.Integer cannot be converted to JSONObject

Expected type did not match the received type

Expected type: java.lang.Integer, actual value: org.hibernate.id.IdentifierGeneratorHelper$2

Error org.json.JSONException: Value 1 at error of type java.lang.Integer cannot be converted to boolean

did not match expected type spring framework error

Custom query Parameter value [2] did not match expected type

Why does JPA TypedQuery throw Exception: Parameter value [...] did not match expected type [java.lang.Character]?

Hibernate: Parameter value did not match expected type?

Error: Parameter value did not match expected type

Hibernate and angular 4+ http get - Parameter value did not match expected type

@ManyToOne Unidirectional Parameter value does not match expected type

JPA + Hibernate currentTimestamp() did not match expected type

Spring Data JPA: InvalidDataAccessApiUsageException: Parameter value [web] did not match expected type [java.util.Collection (n/a)];

Spring JPA @OneToMany Parameter value [] did not match expected type

Parameter value [%Gabrek%] did not match expected type [java.lang.Character (n/a)];

Spring JPA Parameter value [1000] did not match expected type [ma.mycom.myapp.domain.Client (n/a)]

Parameter value [\] did not match expected type [java.lang.String (n/a)]

Parameter value [2019-05-15,23:00] did not match expected type [java.time.LocalDateTime (n/a)]