Skip to content

Dialect is not autodetected on Sql Server 2014 with custom INT sequences #19579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Jan 8, 2020 · 9 comments
Closed
Labels
for: stackoverflow A question that's better suited to stackoverflow.com

Comments

@ghost
Copy link

ghost commented Jan 8, 2020

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))

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 8, 2020
@snicoll
Copy link
Member

snicoll commented Jan 8, 2020

@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?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Jan 8, 2020
@ghost
Copy link
Author

ghost commented Jan 9, 2020

@snicoll I manually choose SQLServer2012Dialect, this is also detected by hibernate but doesn't finish because of the Integer to Long class cast exception.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 9, 2020
@snicoll
Copy link
Member

snicoll commented Jan 9, 2020

@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).

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jan 9, 2020
@ghost
Copy link
Author

ghost commented Jan 9, 2020

@snicoll It only happens when the platform is NOT set.
I will prepare a minimal sample zip.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 9, 2020
@ghost
Copy link
Author

ghost commented Jan 9, 2020

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

@snicoll
Copy link
Member

snicoll commented Jan 9, 2020

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?

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jan 9, 2020
@ghost
Copy link
Author

ghost commented Jan 9, 2020

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.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 9, 2020
@snicoll
Copy link
Member

snicoll commented Jan 9, 2020

@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.

@snicoll snicoll closed this as completed Jan 9, 2020
@snicoll snicoll added for: stackoverflow A question that's better suited to stackoverflow.com and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Jan 9, 2020
@ghost
Copy link
Author

ghost commented Jan 9, 2020

Created a hibernate issue: https://hibernate.atlassian.net/browse/HHH-13805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: stackoverflow A question that's better suited to stackoverflow.com
Projects
None yet
Development

No branches or pull requests

2 participants