HHH-9908 - Regression in naming collection join tables

This commit is contained in:
Steve Ebersole 2015-08-19 10:21:34 -05:00
parent 55eb4a1186
commit 1d5dcf4ad3
1 changed files with 33 additions and 0 deletions

View File

@ -39,6 +39,7 @@ import org.hibernate.annotations.GenericGenerator;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.EJB3NamingStrategy;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.tool.hbm2ddl.SchemaExport;
@ -74,6 +75,33 @@ public class CollectionJoinTableNamingTest extends BaseUnitTestCase {
assertEquals( "ptx_inputs2", inputs2Mapping.getCollectionTable().getName() );
}
@Test
@TestForIssue( jiraKey = "HHH-9908" )
public void testCollectionJoinTableNamingImprovedDelegatorStrategy() {
Configuration cfg = new Configuration();
cfg.setNamingStrategyDelegator( ImprovedNamingStrategyDelegator.DEFAULT_INSTANCE );
cfg.addAnnotatedClass( Input.class );
cfg.addAnnotatedClass( Ptx.class );
cfg.buildMappings();
assertSameTableUsed( cfg );
}
@Test
@TestForIssue( jiraKey = "HHH-9908" )
public void testCollectionJoinTableNamingBase() {
// really the same test as #testCollectionJoinTableNamingJpaCompliantStrategy,
// here we just pick up the (same) NamingStrategy by default
Configuration cfg = new Configuration();
cfg.addAnnotatedClass( Input.class );
cfg.addAnnotatedClass( Ptx.class );
cfg.buildMappings();
assertSameTableUsed( cfg );
}
@Test
@TestForIssue( jiraKey = "HHH-9908" )
public void testCollectionJoinTableNamingJpaCompliantStrategy() {
@ -86,6 +114,10 @@ public class CollectionJoinTableNamingTest extends BaseUnitTestCase {
cfg.addAnnotatedClass( Ptx.class );
cfg.buildMappings();
assertSameTableUsed( cfg );
}
protected void assertSameTableUsed(Configuration cfg) {
Collection inputs1Mapping = cfg.getCollectionMapping( Ptx.class.getName() + ".inputs1" );
assertEquals( "ptx_input", inputs1Mapping.getCollectionTable().getName() );
@ -94,6 +126,7 @@ public class CollectionJoinTableNamingTest extends BaseUnitTestCase {
assertSame( inputs1Mapping.getCollectionTable(), inputs2Mapping.getCollectionTable() );
// NOTE : here so that tester can more easily see the produced table. It is only dumped to stdout
new SchemaExport( cfg ).create( true, false );
for ( int i = 0; i < inputs1Mapping.getCollectionTable().getColumnSpan(); i++ ) {