If entity.getHistory() is null following code snippet:
(getEntityManager() returns spring injected EntityManager, database field history type is: text or varchar2(20
You can cast the parameter to a proper type in the query. I think this solution should work for other databases, too.
Before:
@Query("SELECT person FROM people person"
+ " WHERE (?1 IS NULL OR person.name = ?1)")
List getPeopleWithName(final String name);
After:
@Query("SELECT person FROM people person"
+ " WHERE (?1 IS NULL OR person.name = cast(?1 as string))")
List getPeopleWithName(final String name);
Also works for LIKE statements:
person.name LIKE concat('%', cast(?1 as string), '%')
and with numbers (here of type Double):
person.height >= cast(cast(?1 as string) as double)