Hi All,

I am using a Hibernate named sql query in my app, which contains a 
clause "where deliverydate between :startdate and :enddate".

In my java code, I'm loading this into an org.hibernate.Query object and 
then setting the parameter values like this:

Query query = session.getNamedQuery("delivery.date.range");
query.setParameter("startdate", startDate);
query.setParameter("enddate", endDate);
return query.list();

When I executed this code, I got the following error:
JDBCExceptionReporter.logExceptions | Error:  operator does not exist 
date >= bytea

I had the feeling I should be specifying a type for my query parameters 
(the setParameter method has a third parameter that is an 
org.hibernate.Type type), but I couldn't find a value that seemed 
suitable for a Joda LocalDate object.

In the end, I supplied my date values as java.util.Date types like this:

query.setParameter("startdate", startDate.toDateAtStartOfDay().toDate());

and that allows my tests to pass.  However, I kind of expected the 
joda-hibernate package to have some classes that implement the 
org.hibernate.type 
(http://www.hibernate.org/hib_docs/v3/api/org/hibernate/type/Type.html) 
interface that could be used in query parameters.

Has anyone else used joda date and/or time values in Hibernate named 
queries?  Can you provide any tips for new players?

TIA,

Rob Hills
Waikiki, Western Australia

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to