HHH-7904 corrected CollectionTableNamingStrategyHelper

This commit is contained in:
Brett Meyer 2014-03-25 16:41:48 -04:00
parent c1a5622a7e
commit c7a07a170a
3 changed files with 13 additions and 29 deletions

View File

@ -31,25 +31,18 @@ import org.hibernate.metamodel.spi.relational.Table;
* @author Strong Liu <stliu@hibernate.org>
*/
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
);

View File

@ -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() ) );

View File

@ -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 ) );
}