Joda.time.DateTime with hibernate createQuery for setDate

pojo

public class RateCode implements java.io.Serializable {

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

Inquiry

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 createQuery in criteria.

+3
source share
2 answers

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

Storing Joda DateTime date instead of Java date in Hibernate

+2
source

Please take a look at my project http://usertype.sourceforge.net/ , which will allow you to display Joda time for sleep mode.

Thank you, Chris

+2
source

Source: https://habr.com/ru/post/1793598/


All Articles