Skip to content
Advertisement

JPA Cast BigDecimal as string

I’m using JPA to query a database, but something strange happens. In some cases the cast works and compiles fine, but with a BigDecimal it doesn’t let me use the cast to make a LIKE with a String. Here is a part of the code that works:

JavaScript

pesoObjetivo is a data type Double

JavaScript

But when I try to perform the query with

JavaScript

pesoPregestacional being a BigDecimal

JavaScript

I get the following error

JavaScript

And the rest of my query How could I, inside JPA, do a LIKE operation of the BigDecimal data with a String? Or what is my mistake? By commenting out this line of code or by using

JavaScript

Everything works correctly, it’s just not what I want. So clearly the error is in this sentence

Advertisement

Answer

You missed as string:

Wrong

JavaScript

Correct

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement