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;
|
||||
|
||||
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.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.dialect.OracleDialect;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaValidator;
|
||||
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.orm.junit.BaseSessionFactoryFunctionalTest;
|
||||
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.BeforeAll;
|
||||
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
|
||||
* identical entity, but using the synonym name.
|
||||
|
@ -37,27 +37,51 @@ import org.junit.jupiter.api.Test;
|
|||
*
|
||||
* @author Brett Meyer
|
||||
*/
|
||||
@RequiresDialect(value = OracleDialect.class)
|
||||
@RequiresDialects(
|
||||
value = {
|
||||
@RequiresDialect(value = OracleDialect.class),
|
||||
@RequiresDialect(value = DB2Dialect.class),
|
||||
}
|
||||
)
|
||||
public class SynonymValidationTest extends BaseSessionFactoryFunctionalTest {
|
||||
|
||||
private StandardServiceRegistry ssr;
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {TestEntity.class};
|
||||
return new Class<?>[] { TestEntity.class };
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public void setUp() {
|
||||
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
|
||||
public void tearDown() {
|
||||
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();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -83,7 +107,7 @@ public class SynonymValidationTest extends BaseSessionFactoryFunctionalTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-12406")
|
||||
@TestForIssue(jiraKey = "HHH-12406")
|
||||
public void testSynonymUsingDefaultStrategySchemaValidator() {
|
||||
// Hibernate should use JdbcMetadaAccessStrategy.INDIVIDUALLY when
|
||||
// AvailableSettings.ENABLE_SYNONYMS is true.
|
||||
|
@ -103,7 +127,7 @@ public class SynonymValidationTest extends BaseSessionFactoryFunctionalTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-12406")
|
||||
@TestForIssue(jiraKey = "HHH-12406")
|
||||
public void testSynonymUsingGroupedSchemaValidator() {
|
||||
// Hibernate should use JdbcMetadaAccessStrategy.INDIVIDUALLY when
|
||||
// AvailableSettings.ENABLE_SYNONYMS is true,
|
||||
|
|
Loading…
Reference in New Issue