mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-09 04:34:49 +00:00
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.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,27 +37,51 @@
|
|||||||
*
|
*
|
||||||
* @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;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
return new Class<?>[] {TestEntity.class};
|
return new Class<?>[] { TestEntity.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
@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();
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +107,7 @@ public void testSynonymUsingIndividuallySchemaValidator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-12406")
|
@TestForIssue(jiraKey = "HHH-12406")
|
||||||
public void testSynonymUsingDefaultStrategySchemaValidator() {
|
public void testSynonymUsingDefaultStrategySchemaValidator() {
|
||||||
// Hibernate should use JdbcMetadaAccessStrategy.INDIVIDUALLY when
|
// Hibernate should use JdbcMetadaAccessStrategy.INDIVIDUALLY when
|
||||||
// AvailableSettings.ENABLE_SYNONYMS is true.
|
// AvailableSettings.ENABLE_SYNONYMS is true.
|
||||||
@ -103,7 +127,7 @@ public void testSynonymUsingDefaultStrategySchemaValidator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-12406")
|
@TestForIssue(jiraKey = "HHH-12406")
|
||||||
public void testSynonymUsingGroupedSchemaValidator() {
|
public void testSynonymUsingGroupedSchemaValidator() {
|
||||||
// Hibernate should use JdbcMetadaAccessStrategy.INDIVIDUALLY when
|
// Hibernate should use JdbcMetadaAccessStrategy.INDIVIDUALLY when
|
||||||
// AvailableSettings.ENABLE_SYNONYMS is true,
|
// AvailableSettings.ENABLE_SYNONYMS is true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user