diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/binder/CollectionTableNamingStrategyHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/binder/CollectionTableNamingStrategyHelper.java index 9c27aa2c90..6b07f50730 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/binder/CollectionTableNamingStrategyHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/binder/CollectionTableNamingStrategyHelper.java @@ -31,25 +31,18 @@ import org.hibernate.metamodel.spi.relational.Table; * @author Strong Liu */ public class CollectionTableNamingStrategyHelper extends TableNamingStrategyHelper { - private final String ownerTableLogicalName; private final String propertyName; public CollectionTableNamingStrategyHelper(final AbstractPluralAttributeBinding pluralAttributeBinding) { super( pluralAttributeBinding.getContainer().seekEntityBinding() ); - this.ownerTableLogicalName = - Table.class.isInstance( entityBinding.getPrimaryTable() ) - ? ( (Table) entityBinding.getPrimaryTable() ).getPhysicalName().getText() - : null; this.propertyName = Binder.createAttributePath( pluralAttributeBinding ); } @Override public String determineImplicitName(NamingStrategy strategy) { - - return strategy.collectionTableName( entityBinding.getEntityName(), - ownerTableLogicalName, + strategy.classToTableName( entityBinding.getEntityName() ), null, null, propertyName @@ -61,7 +54,7 @@ public class CollectionTableNamingStrategyHelper extends TableNamingStrategyHelp public String getLogicalName(NamingStrategy strategy) { return strategy.logicalCollectionTableName( logicalName, - ownerTableLogicalName, + strategy.classToTableName( entityBinding.getEntityName() ), null, propertyName ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java index 91e0ccf311..8ada756b5d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java @@ -23,6 +23,10 @@ */ package org.hibernate.test.annotations.embedded; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -31,18 +35,13 @@ import java.util.Set; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; - -import org.hibernate.testing.FailureExpectedWithNewMetamodel; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.test.annotations.embedded.FloatLeg.RateIndex; import org.hibernate.test.annotations.embedded.Leg.Frequency; import org.hibernate.test.util.SchemaUtil; +import org.hibernate.testing.FailureExpectedWithNewMetamodel; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - /** * @author Emmanuel Bernard */ @@ -407,7 +406,6 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testDefaultCollectionTable() throws Exception { //are the tables correct? assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", metadata() ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java index 805737906f..66f64cddb4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java @@ -1,6 +1,9 @@ // $Id$ package org.hibernate.test.annotations.namingstrategy; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + import java.io.PrintWriter; import java.io.StringWriter; @@ -9,20 +12,14 @@ import org.hibernate.cfg.Environment; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.spi.MetadataImplementor; import org.hibernate.service.ServiceRegistry; - -import org.hibernate.testing.FailureExpectedWithNewMetamodel; +import org.hibernate.test.util.SchemaUtil; import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.hibernate.test.util.SchemaUtil; +import org.jboss.logging.Logger; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.jboss.logging.Logger; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - /** * Test harness for ANN-716. * @@ -60,7 +57,6 @@ public class NamingStrategyTest extends BaseUnitTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testWithEJB3NamingStrategy() throws Exception { MetadataSources metadataSources = new MetadataSources() .addAnnotatedClass( A.class ) @@ -68,9 +64,6 @@ public class NamingStrategyTest extends BaseUnitTestCase { MetadataImplementor metadata = (MetadataImplementor) metadataSources.getMetadataBuilder() .with( EJB3NamingStrategy.INSTANCE ) .build(); - - // todo : naming strategy is not applied - assertNotNull( SchemaUtil.getTable( "A_ADDRESS", metadata ) ); }