Reputation: 3281
I have this code in my dao method:
TypedQuery<Application> query = em.createQuery(
"FROM Application a "
+ "WHERE LOWER(a.candidate.firstName LIKE :firstName) "
+ "OR LOWER(a.candidate.lastName LIKE :lastName) "
+ "OR (a.candidate.phoneNumber LIKE :phoneNumber) "
+ "OR LOWER(a.candidate.email LIKE :email) "
+ "OR LOWER(a.candidate.postcode LIKE :postcode)"
, Application.class);
query = query.setParameter("firstName", candidate.getFirstName());
query = query.setParameter("lastName", candidate.getLastName());
query = query.setParameter("phoneNumber", candidate.getPhoneNumber());
query = query.setParameter("email", candidate.getEmail());
query = query.setParameter("postcode", candidate.getPostcode());
and it throws this Exception:
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: ( near line 1, column 57 [FROM com.xxx.xxx.entity.Application a WHERE LOWER(a.candidate.firstName LIKE :firstName) OR LOWER(a.candidate.lastName LIKE :lastName) OR (a.candidate.phoneNumber LIKE :phoneNumber) OR LOWER(a.candidate.email LIKE :email) OR LOWER(a.candidate.postcode LIKE :postcode)]
Something is probably wrong with my query, but I cannot see what... Any help appreciated.
Upvotes: 0
Views: 162
Reputation: 658
It's your parenthesis.
LOWER(a.candidate.firstName LIKE :firstName)
should be:
LOWER(a.candidate.firstName) LIKE :firstName
etc.
Upvotes: 3