Monday, July 2, 2012

Hibernate: Map Separate Date and Time Columns to a Date

I ran into a problem where I was trying to get Hibernate to map seperate date and time columns from an SQL Server to one Date object

In my query editor CAST(from_date AS DATETIME) + CAST(from_time AS TIME) worked just fine so I plugged it into a @Formula, but it turns out Hibernate really wanted to put the table alias in from of the keyword DATETIME(HHH-2967)

After some cursing at Hibernate I finally came up with a formula that works

Simply put, I'm just converting the date to a string and then concatenating the time as a string. Fairly simple, but a pain.

No comments:

Post a Comment