3

pojo

public class RateCode implements java.io.Serializable {

     private org.joda.time.DateTime travelTo;
     private org.joda.time.DateTime bookingFrom;
}

Query

Query q = session.createQuery(
                "from RateCode rr where rr.id.date>=:from and rr.id.date<=:to order by rr.id.date").setDate("from", from).setDate("to", to);

But setDate/setTimeStamp Require util.Date.

ERROR: java.lang.NoSuchFieldError: TIMESTAMP
        at org.joda.time.contrib.hibernate.PersistentDateTime.nullSafeSet(PersistentDateTime.java:83)

so how to set in createQuery criteria.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Ravi Parekh
  • 5,253
  • 9
  • 46
  • 58

2 Answers2

2

You can use custom user types created for joda-time. You can download it here

Persisting Joda DateTime instead of Java Date in Hibernate

Community
  • 1
  • 1
Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
2

Please take a look at my project, http://usertype.sourceforge.net/ which will let you map Joda Time to Hibernate.

Thanks Chris

Chris Pheby
  • 323
  • 1
  • 8