Hibernate: On SQL Server 2008 column was altered from datetime to datetime2. How I can update hibernate config to reflect this?

I have an application in which I created mappings of entities in Hibernate, so I could have access to some legacy tables on SQL Server 2005. Everything was working fine and as expected until the database was switched to a newer version of SQL Server – specifically, to SQL Server 2008.

As the data were moved, all datetime columns in tables were changed to datetime2 and now, while starting the webapp on tomcat I receive an error:

  • Is there a quick way to report database metadata in SQL Server 2005?
  • Which DataType should be used for Editor & File and image browser
  • white circle in microsoft SQL server management studio 2012
  • SQL Server: how to include count in the select query with where clause?
  • SQL Server 2008 Express Grant User Permission
  • Evaluating XQuery/XPath expressions from table
  • Caused by: org.hibernate.HibernateException: Wrong column type (...)
    Found: datetime2, expected: datetime

    What is the proper way of changing the config in hibernate to reflect this change? All entities are defined using annotations wherever possible, all database specific c

    I don’t know if this is relevant but here are the versions of software which I am using:

    • Hibernate 3.6.4.Final
    • jTDS driver 1.2.5

    Thank you very much.

    Edit: solution found

    Thanks to ManuPK suggestions, I had switched from jTDS to Microsoft driver, sadly, after updating the settings of the webapp, I still received the same error. I solved it by creating custom class which is extending the SQLServer2008Dialect and registered datetime2 as new column type. I don’t know if this is the proper solution, but it works.

    public class UpdatedSQLServerDialect extends SQLServer2008Dialect {
       public UpdatedSQLServerDialect () {
          registerColumnType(Types.DATE, "datetime2");

  • how to configure hibernate config file for sql server
  • Hibernate (/JPA) server-side paging and MS SQL Server
  • sql stop count at a given threshold
  • Hibernate @GeneratedValue null error for primary key
  • Getting Hibernate and SQL Server to play nice with VARCHAR and NVARCHAR
  • Creating field with reserved word name with JPA
  • One Solution collect form web for “Hibernate: On SQL Server 2008 column was altered from datetime to datetime2. How I can update hibernate config to reflect this?”

    As you have told, in MS SQL Server 2008 datetime is deprecated and they have added a new type datetime2. You can continue using the java.lang.Date object to map this column in the bean.

    You seems to have problem in the SQL Driver (jTDS driver 1.2.5) you are using. Get the new version of the jar from here. I am able to use the datetime2 datatype with this Jar.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.