• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Problem with between expresion (EJB QL)

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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???
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic