AddThis

Thursday, August 18, 2011

No Time for SQL Date

We have a stored proc (ugh) that is called from within Hibernate.  We pass in values to this stored proc using the type, java.sql.Date.  The stored proc then does comparisons against some date column against the date object we passed in, but we were noticing that the time portion was being ignored!  The answer was simple and frustrating, java.sql.Date ignores time (should have read the javadocs sooner) :( We had to instead use java.sql.Time.  I would have much rather preferred we NOT use stored procs.  A few quick benchmarks and noticed that the stored proc to get a count versus a Hibernate projection was on average four times slower.  What can you do when the client loves stored procs?

http://download.oracle.com/javase/6/docs/api/java/sql/Date.html
Post a Comment