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
  • 390,936
  • 96
  • 800
  • 764
Ravi Parekh
  • 4,533
  • 8
  • 41
  • 55

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
  • 76,625
  • 45
  • 224
  • 313
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