Hi have a db with 3 schemas c##andrea, c##hibernate, c##other I have created a table c##other.PERSON(id, name) , a synonym c##andrea.PERSON_SYN and a table c##andrea.ADDRESS(id,city) then I run the following test:
public class TestOracleSchemaValidation extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] {Person.class, Address.class};
}
@Override
protected boolean createSchema() {
return false;
}
@Override
protected void configure(Configuration configuration) {
configuration.setProperty( AvailableSettings.HBM2DDL_AUTO, "validate" );
configuration.setProperty( AvailableSettings.ENABLE_SYNONYMS, "true" );
configuration.setProperty(
AvailableSettings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY,
JdbcMetadaAccessStrategy.INDIVIDUALLY.toString()
);
}
@Test
public void testIt() throws Exception {
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
final Address address = new Address();
address.setId( 1 );
address.setCity( "London" );
session.save( address );
} );
}
@Entity
@Table(name = "PERSON_SYN", schema = "c##andrea")
public class Person {
@Id
int id;
String name;
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
}
@Entity
@Table(name = "ADDRESS", schema = "c##andrea")
public class Address {
@Id
int id;
String city;
public void setId(int id) {
this.id = id;
}
public void setCity(String city) {
this.city = city;
}
}
}
with the config
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.username=c##hibernate
hibernate.connection.password=hibernate_orm_test
hibernate.connection.url=jdbc\:oracle\:thin\:@localhost\:1521\:ORCLCDB
and it works fine, no validation errors. |