-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: DB2 preparedStatement timestamp/date problem
PostPosted: Sat Aug 14, 2004 9:28 am 
Newbie

Joined: Thu May 06, 2004 8:14 pm
Posts: 18
Hi, we are using Hibernate 2.1.2 with DB/2 8.1.3 with IBM's Universal Type 4 driver (db2jcc.jar).

We have a piece of code which does this:

Query q = session.createQuery("from Foobar f where f.dateCreated > :date");
q.setDate("date", new Date());

This gives us a -301 Type Mismatch error. The dateCreated column type is TIMESTAMP. If I change the Date to a java.sql.Date or a java.sql.Timestamp, neither works. If I write some pure JDBC code, I can get it to work if I call setTimestamp() on the preparedStatement instead of setDate().

Is there any sort of workaround here to get this working in Hibernate? I'm using the standard DB2Dialect, is there a better dialect to use that might have this fixed?

mike


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 14, 2004 9:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
q.setTimestamp( new Date() )


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 14, 2004 10:47 am 
Newbie

Joined: Thu May 06, 2004 8:14 pm
Posts: 18
There must be a natural law which says the longer you look at a problem, the less likely you are to see the obvious answer. Thank you, Gavin.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.