Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate using datetime2 with SQLServer2005 instead of datetime

 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks- I'm using Hibernate 3.6.1, SQLServer2005 and jtds 1.2.5 driver. The dialect setting is:



For an Entity with field of type:

hibernate produces SQL with data type:

Problem is datetime2 is a MS SQLServer2008 type and is not available in SQLServer2005.

How can I tell hibernate it's SQLServer2005 and not SQLServer2008? I couldn't find any hibernate.dialect for SQLServer2005.

Any help will be greatly appreciated.
 
Anantha Sharma
Ranch Hand
Posts: 43
Android Hibernate jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
unfortunately, hibernate only knows that you are using sql server (it cannot differentiate between the different versions of the db like 2005, 2008 etc)

you could try to tell hibernate to use datetime using the type attribute

ex:

<property name="someDateField" type="datetime"/>


refer to http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-property for furthur info.

Regards,
Anantha Sharma
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic