Search code examples
javaspringopenjpaspring-data-jpa

Exception calling spring data jpa query method with suffix "IN" against primitive type on openjpa


I have the following jpa data query method:

findByEntityIdIn(List<Long> entities);

And on my persistent object I have a long type persisent field called "entityId".

When I call this method on openjpa I get the following exception...

org.springframework.dao.InvalidDataAccessApiUsageException: Filter invalid. Cannot compare field entityId of type long to value of type java.util.Collection. Numeric comparisons must be between numeric types only. To enable such comparisons for backwards-compatibility, add "QuotedNumbersInQueries=true" to the org.apache.openjpa.Compatibility setting in your configuration.; nested exception is org.apache.openjpa.persistence.ArgumentException: Filter invalid. Cannot compare field entityId of type long to value of type java.util.Collection. Numeric comparisons must be between numeric types only. To enable such comparisons for backwards-compatibility, add "QuotedNumbersInQueries=true" to the org.apache.openjpa.Compatibility setting in your configuration.

Should I just do what it recommends or is there another solution? Basically it sounds like I can only use collections against string data types without the configuration parameter as it quotes each entry in the passed in collection.


Solution

  • This is a bug in OpenJPA. We recommend to use a different persistence provider.