Query in Spring Data error Like for Integer records

#1

Hi!,

Does anyone know how I can use this type of Query with Like and that does not give an error when you search in an Integer type field?

I have been forced to change the "CodigoTienda" record in my entity from an Integer type to a String type.

Greetings.

#2

Interesting question. LIKE is a query operator for strings not for numbers, and apparently JPA does not define a standard method for converting numbers to strings.

However, you can make use of the ObjectDB ability to run Java methods in queries and convert numbers to strings using the static method String.valueOf, e.g. "String.valueOf(t.codigoTienda)".

ObjectDB Support

Reply