HHH-15585 Add test for issue
This commit is contained in:
parent
42890e3a8d
commit
b1f92863cb
|
@ -6,16 +6,11 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.schemavalidation;
|
package org.hibernate.orm.test.schemavalidation;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.GeneratedValue;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
|
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.OracleDialect;
|
import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaValidator;
|
import org.hibernate.tool.hbm2ddl.SchemaValidator;
|
||||||
import org.hibernate.tool.schema.JdbcMetadaAccessStrategy;
|
import org.hibernate.tool.schema.JdbcMetadaAccessStrategy;
|
||||||
|
@ -23,11 +18,16 @@ import org.hibernate.tool.schema.JdbcMetadaAccessStrategy;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
|
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
|
||||||
import org.hibernate.testing.orm.junit.RequiresDialect;
|
import org.hibernate.testing.orm.junit.RequiresDialect;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialects;
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the BaseCoreFunctionalTestCase to create the schema using TestEntity. The test method validates against an
|
* Allows the BaseCoreFunctionalTestCase to create the schema using TestEntity. The test method validates against an
|
||||||
* identical entity, but using the synonym name.
|
* identical entity, but using the synonym name.
|
||||||
|
@ -37,7 +37,12 @@ import org.junit.jupiter.api.Test;
|
||||||
*
|
*
|
||||||
* @author Brett Meyer
|
* @author Brett Meyer
|
||||||
*/
|
*/
|
||||||
@RequiresDialect(value = OracleDialect.class)
|
@RequiresDialects(
|
||||||
|
value = {
|
||||||
|
@RequiresDialect(value = OracleDialect.class),
|
||||||
|
@RequiresDialect(value = DB2Dialect.class),
|
||||||
|
}
|
||||||
|
)
|
||||||
public class SynonymValidationTest extends BaseSessionFactoryFunctionalTest {
|
public class SynonymValidationTest extends BaseSessionFactoryFunctionalTest {
|
||||||
|
|
||||||
private StandardServiceRegistry ssr;
|
private StandardServiceRegistry ssr;
|
||||||
|
@ -50,14 +55,33 @@ public class SynonymValidationTest extends BaseSessionFactoryFunctionalTest {
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
inTransaction(
|
inTransaction(
|
||||||
session -> session.createNativeQuery( "CREATE SYNONYM test_synonym FOR test_entity" ).executeUpdate()
|
session -> {
|
||||||
|
final String createStatement;
|
||||||
|
if ( getDialect() instanceof OracleDialect ) {
|
||||||
|
createStatement = "CREATE SYNONYM test_synonym FOR test_entity";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
createStatement = "CREATE ALIAS test_synonym FOR test_entity";
|
||||||
|
}
|
||||||
|
session.createNativeQuery( createStatement ).executeUpdate();
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
inTransaction(
|
inTransaction(
|
||||||
session -> session.createNativeQuery( "DROP SYNONYM test_synonym FORCE" ).executeUpdate()
|
session ->
|
||||||
|
{
|
||||||
|
final String dropStatement;
|
||||||
|
if ( getDialect() instanceof OracleDialect ) {
|
||||||
|
dropStatement = "DROP SYNONYM test_synonym FORCE";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dropStatement = "DROP ALIAS test_synonym FOR TABLE";
|
||||||
|
}
|
||||||
|
session.createNativeQuery( dropStatement ).executeUpdate();
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue