See issue #16172
Dialect is not detected when a Microsoft Sql Server 2014 database is used in combination with custom sequences of INT type. The sequence was created the following way: create sequence example as INT start with 42 increment by 1 no cache
This occurs only if jpa.database-platform is not set. Spring Boot 2.2.2 with Java 8 and mssql-jdbc 7.4.1.jre8 is used.
Spring Boot Exception: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
After debugging I found out that hibernates SequenceInformationExtractorLegacyImpl#extractMetadata fails. This is caused because in SequenceInformationExtractorLegacyImpl#resultSetStartValueSize() it calls resultSet.getLong() which fails with 'java.lang.Integer' to 'java.lang.Long' exception from the Microsoft Jdbc driver (SqlServerResultSet#getLong(String))
Comment From: snicoll
@40305561 If that works when you set the database platform, this is likely to be a Hibernate issue. What version did you use that worked and what version was selected when the property was not set?
Comment From: ghost
@snicoll I manually choose SQLServer2012Dialect, this is also detected by hibernate but doesn't finish because of the Integer to Long class cast exception.
Comment From: snicoll
@40305561 Sorry I don't understand. In your original description you're stating that "it only happens when the platform is set" which led me to believe that something was detecting the wrong dialect.
Can you please clarify? Sharing a small sample that reproduces the issue would be idea (a zip or github repo of a project we can run ourselves).
Comment From: ghost
@snicoll It only happens when the platform is NOT set. I will prepare a minimal sample zip.
Comment From: ghost
I added a minimal demo project. dialectdemo.zip Of course you need a Microsoft Sql Server with the custom int sequence to reproduce it. The connection is setup in application.yml
Comment From: snicoll
Thanks for the sample. This helps me making sure that there isn't anything else going on in the project and the version of Spring Boot you're using.
@snicoll It only happens when the platform is NOT set.
Yes, sorry about that. If the platform is not set, Hibernate is deciding which dialect to use. If that doesn't work, then it is very much likely to be a Hibernate issue. I fail to see, based on your sample, what it could be and how Spring Boot participates in your issue.
Can you please double check that the dialect are the same when the platform is set and when it is not set?
Comment From: ghost
Yes the dialects are the same when the platform is set and when it is not set (in both cases SQLServer2012Dialect), also the old spring boot dialect discovery (before it switched to hibernate dialect discovery in 2.2) recognized SQLServer2012Dialect.
Do you now how to submit a Hibernate Issue? I know what goes wrong in the Hibernate Code, but my hibernate knowledge is very limited.
Comment From: snicoll
@40305561 thanks for the feedback. The Hibernate issue tracker is on Jira. I am going to close this issue now, we can reopen if it turns out to be an issue in Spring Boot after all.
Comment From: ghost
Created a hibernate issue: https://hibernate.atlassian.net/browse/HHH-13805