Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with between expresion (EJB QL)  RSS feed

Laura Barroso
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm having problems with this query:
Timestamp initialDate= Timestamp.valueOf("2010-11-11 10:00:00");
Timestamp finalDate= Timestamp.valueOf("2010-11-11 10:00:00");
String deviceId = "001";
Query query = entityManager.createQuery("from StoredMobileState s where " +
"lower(s.deviceId) = lower(:deviceId) and " +
"s.localTimestamp between "+initialDate+" and "+finalDate);
query.setParameter("deviceId", deviceId);
query.setParameter("initialDate", initialDate);
query.setParameter("finalDate", finalDate);

When I try it my server gives me this exception:
java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 10 near line 1, column 131 [from org.desoft.dcp.entity.StoredMobileState s where lower(s.deviceId) = lower(:deviceId) and s.localTimestamp between 2010-11-11 10:00:00.0 and 2010-11-11 10:01:00.0]

finalDate and initialDate are Timestamp objects...Does anyone knows how to fix this???
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!