Getting NullPointerException while using Hibernate like escape via JPA predicate
Issue
-
Using search predicates to the underlying JPA implementation (
Hibernate 4.2.7SP1) -
If I create a
LIKEpredicate with an escape character, I get multipleNullPointerExceptionoccurrences when trying to process the resultingSQL prepared statement. -
This appears to be because the escape character is added as an additional parameter in the prepared statement and no type information is provided.
-
That seems at odds with the code in the registerParameters() implementation, but I get no stack trace for any of the exceptions.
-
Following is an example of generated SQL:
select count(user0_.id) as col_0_0_ from organization_user user0_ where user0_.organization_name like ? escape '\' and (lower(user0_.username) like ? escape ? or lower(user0_.given_name) like ? escape ?)
- The expectation is that, the escape character would have been treated as a literal and added to the text. Instead, the code in
org.hibernate.ejb.criteria.predicate.LikePredicaterenders the escape as an additional parameter.
Environment
-
Hibernate 4.2.7SP1
-
org.hibernate.dialect.HSQLDialect
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
