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?

1 comment:

Jon V said...

You convince the client that this isn't the way to do it. Use the speed data collected to prove why it's not the optimal solution for that case. Eventually, you get rid of all of the stored procs...