Schema validation fails on SQL Server 2012 and Oracle - Hibernate bug
- [x ] Steps to reproduce provided
- [x ] Stacktrace (if present) provided
- [ ] Example that reproduces the problem uploaded to Github
- [ ] Full description of the issue provided (see below)
Steps to Reproduce
- Create a basic application using Grails 3.3.0
- Create a simple domain class with just one field
- Add "provided 'com.microsoft.sqlserver:sqljdbc4:4.0'" to "build.gradle"
- Set the datasource using "dbCreate: update" and "dialect: org.hibernate.dialect.SQLServer2012Dialect"
- Run the application and let Grails creates the table
- Stop the application and set "dbCreate" to "validate"
- Re-run the application
I'm expecting the application starts correctly, by validating the table just created.
The application fails to start, reporting schema validation error: the validation process can't find the table previously created (Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table)
- Operating System: Win10 x64
- Grails Version: 3.3.0 (GORM 6.1.6.RELEASE)
- JDK Version: 1.8 update 131 x64
- Container Version (If Applicable): Embedded tomcat
- 点赞 评论 复制链接分享
- weixin_39989668 4月前
👍 ran into the same issue - had to set dbCreate to 'none' as a workaround (skipping validation).点赞 评论 复制链接分享
- weixin_39957805 4月前
Upload an example project点赞 评论 复制链接分享
Hi , I can't provide an example at the moment (in these days I'm using a PC not mine and without Grails because I'm not at work), but you can create an example by following the steps provided above.点赞 评论 复制链接分享
Doesn't seem that the problem is specific to Grails 3.3
I setup SQL Server with Docker and both Grails 3.2 (with GORM 6) and Grails 3.3 (with GORM 6.1) produce the same exception.
In debugging no tables are returned from the JDBC metadata so Hibernate throws an exception. I am unsure why the SQL server Java driver are not returning the table metadata. The issue has also been reported against Oracle it seems #10768
Seems like a Hibernate bug to me, not sure what we can do about it.点赞 评论 复制链接分享
https://hibernate.atlassian.net/browse/HHH-11440 seems related点赞 评论 复制链接分享
Problem can be resolved by configuration in
yaml hibernate: hbm2ddl: jdbc_metadata_extraction_strategy: individually
I guess we may need to make this the default.点赞 评论 复制链接分享
- weixin_39963465 4月前
According to https://hibernate.atlassian.net/browse/HHH-11440 it has been fixed in Hibernate 5.1.13 can you please upgrade your Hiberate dependency to
compile "org.hibernate:hibernate-core:5.1.13.Final"and let us know if it works without the workaround?点赞 评论 复制链接分享
thanks a lot, I'll try ASAP点赞 评论 复制链接分享
- weixin_39682511 4月前
Just an FYI - I tried the workaround with Hibernate 5.1.5 (default for Grails 3.3.8) and I tried using Hibernate 5.1.13 with Grails 3.3.8 and both seem to work correctly.
Hopefully Grails 3.3.9 and above will use a newer version of Hibernate so this issue goes away!点赞 评论 复制链接分享
- weixin_39963465 4月前
I have an open PR to upgrade Hibernate to
5.1.16.Finalthat will be included in Grails 3.3.9: https://github.com/grails/grails-core/issues/11065点赞 评论 复制链接分享
- weixin_39713833 4月前
and , both the workaround described above and the upgrade to Hibernate 5.1.13 worked like a charm here. I'm using Grails 3.3.6 with SQL Server 2017 (docker for Linux). Thank you very much.点赞 评论 复制链接分享