My Grails 3.3.2 application currently connecting to an Oracle 11g database and some of the data tables are synonyms with dblink that point to the physical table in another database. When the Grails application startup, below hibnerate exception was threw:
org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing column [col_in_tbl_with_synonyms] in table [tbl_with_synonyms]
Many articles say that the connection property includeSynonyms
has to be set to true
in order to let Oracle return the meta data so that hibernate can find the column definition. So I tried to set the includeSynonyms=true
in different ways but still not getting it work and always getting above error, no matter I used ojdbc6 or ojbc8 driver.
I know I can set dbCreate: none
to bypass the validation as workaround, but with validation can find out the mapping problem earlier which should be a good idea.
Below is my configuration for reference, any idea? Thanks!
build.gradle
bootRun {
jvmArgs = ['-Doracle.jdbc.includeSynonyms=true']
}
application.yml
spring:
...
datasource:
dbProperties:
includeSynonyms: true
synonyms: true
connectionProperties:
includeSynonyms: true
synonyms: true
connection-properties:
includeSynonyms: true
synonyms: true
hibernate:
...
synonyms: true
includeSynonyms: true
dataSources:
dataSource:
driverClassName: oracle.jdbc.OracleDriver
dialect: org.hibernate.dialect.Oracle10gDialect
dbCreate: validate
dbProperties:
includeSynonyms: true
synonyms: true
connectionProperties:
includeSynonyms: true
synonyms: true
connection-properties:
includeSynonyms: true
synonyms: true
...
properties:
...
includeSynonyms: true
synonyms: true
dbProperties:
includeSynonyms: true
synonyms: true
connectionProperties:
includeSynonyms: true
synonyms: true
connection-properties:
includeSynonyms: true
synonyms: true