Issue
We are migrating from DB2 to MSSQL DB, and am at the stage of configuring our app which is on Hibernate to connect to the MSSQL DB. Connection to the MSSQL DB has been established, but these 2 errors are being thrown up and the app initialization fails:
Caused by: org.hibernate.MappingException:Could not instantiate id generator
and
Caused by: org.hibernate.MappingException:Dialect does not support sequences
Our hibernate configuration is xml based, and all the table configurations are similar and as below:
<generator class="assigned">
or
<generator class="native">
Most of the solutions I have read have to deal with annotation styles configs, which we cannot move over to. What should be the equivalent xml configuration of GENERATOR strategy AUTO or IDENTITY? MSSQL supposedly also does not support sequences in this context, but then doesn't a part of the purpose of Hibernate where it is supposed to be a ORM where you just need to change connections params, and bingo, connected to another DB system, fails?
Solution
The MSSQL DB being used is version 15 (2019), which needs an upgraded Dialect. Upgrading Hibernate to 4.3.9.Final from 3.2.5.ga, and changing dialect to this solved the problem, without any other changes to the sequences or mapping files
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServer2012Dialect"</prop>
Answered By - Sobin George