i fetch records between 2 dates. query below not working. tried following:
1. employee emp_gkey=121 , empcreated between '2016-08-29 00:00:00.0' , '2016-09-02 00:00:0.0'; 2. employee emp_gkey=121 having empcreated between '2016-08-29 00:00:00.0' , '2016-09-02 00:00:0.0'; 3. employee emp_gkey=121 , empcreated >= '2016-08-29 00:00:00.0' , empcreated <= '2016-09-02 00:00:0.0';
please kindly help. using oracle database , hibernate column type defined "timestamp".
thanks.
in hql queries, parameters need same type/class mapped property in entity.
you need this:
final typedquery<employee> query = em.createquery("select e employee e e.empcreated between :from , :to"); query.setparameter("from", new date()); query.setparameter("to", new date());
given type of empcreated variable date
.
i'm using standard jpa here (jpql), i'll leave convert method calls whatever using..
in general, when writing hql/jpql queries, have forget how database looks. queries against entities (java classes), not database tables!
Comments
Post a Comment