HHH-7904 corrected CollectionTableNamingStrategyHelper
This commit is contained in:
parent
c1a5622a7e
commit
c7a07a170a
|
@ -31,25 +31,18 @@ import org.hibernate.metamodel.spi.relational.Table;
|
||||||
* @author Strong Liu <stliu@hibernate.org>
|
* @author Strong Liu <stliu@hibernate.org>
|
||||||
*/
|
*/
|
||||||
public class CollectionTableNamingStrategyHelper extends TableNamingStrategyHelper {
|
public class CollectionTableNamingStrategyHelper extends TableNamingStrategyHelper {
|
||||||
private final String ownerTableLogicalName;
|
|
||||||
private final String propertyName;
|
private final String propertyName;
|
||||||
|
|
||||||
public CollectionTableNamingStrategyHelper(final AbstractPluralAttributeBinding pluralAttributeBinding) {
|
public CollectionTableNamingStrategyHelper(final AbstractPluralAttributeBinding pluralAttributeBinding) {
|
||||||
super( pluralAttributeBinding.getContainer().seekEntityBinding() );
|
super( pluralAttributeBinding.getContainer().seekEntityBinding() );
|
||||||
this.ownerTableLogicalName =
|
|
||||||
Table.class.isInstance( entityBinding.getPrimaryTable() )
|
|
||||||
? ( (Table) entityBinding.getPrimaryTable() ).getPhysicalName().getText()
|
|
||||||
: null;
|
|
||||||
this.propertyName = Binder.createAttributePath( pluralAttributeBinding );
|
this.propertyName = Binder.createAttributePath( pluralAttributeBinding );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String determineImplicitName(NamingStrategy strategy) {
|
public String determineImplicitName(NamingStrategy strategy) {
|
||||||
|
|
||||||
|
|
||||||
return strategy.collectionTableName(
|
return strategy.collectionTableName(
|
||||||
entityBinding.getEntityName(),
|
entityBinding.getEntityName(),
|
||||||
ownerTableLogicalName,
|
strategy.classToTableName( entityBinding.getEntityName() ),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
propertyName
|
propertyName
|
||||||
|
@ -61,7 +54,7 @@ public class CollectionTableNamingStrategyHelper extends TableNamingStrategyHelp
|
||||||
public String getLogicalName(NamingStrategy strategy) {
|
public String getLogicalName(NamingStrategy strategy) {
|
||||||
return strategy.logicalCollectionTableName(
|
return strategy.logicalCollectionTableName(
|
||||||
logicalName,
|
logicalName,
|
||||||
ownerTableLogicalName,
|
strategy.classToTableName( entityBinding.getEntityName() ),
|
||||||
null,
|
null,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.embedded;
|
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.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -31,18 +35,13 @@ import java.util.Set;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
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.FloatLeg.RateIndex;
|
||||||
import org.hibernate.test.annotations.embedded.Leg.Frequency;
|
import org.hibernate.test.annotations.embedded.Leg.Frequency;
|
||||||
import org.hibernate.test.util.SchemaUtil;
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
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
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
|
@ -407,7 +406,6 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testDefaultCollectionTable() throws Exception {
|
public void testDefaultCollectionTable() throws Exception {
|
||||||
//are the tables correct?
|
//are the tables correct?
|
||||||
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", metadata() ) );
|
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", metadata() ) );
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
package org.hibernate.test.annotations.namingstrategy;
|
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.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
@ -9,20 +12,14 @@ import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.metamodel.MetadataSources;
|
import org.hibernate.metamodel.MetadataSources;
|
||||||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
|
||||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.hibernate.test.util.SchemaUtil;
|
import org.jboss.logging.Logger;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
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.
|
* Test harness for ANN-716.
|
||||||
*
|
*
|
||||||
|
@ -60,7 +57,6 @@ public class NamingStrategyTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testWithEJB3NamingStrategy() throws Exception {
|
public void testWithEJB3NamingStrategy() throws Exception {
|
||||||
MetadataSources metadataSources = new MetadataSources()
|
MetadataSources metadataSources = new MetadataSources()
|
||||||
.addAnnotatedClass( A.class )
|
.addAnnotatedClass( A.class )
|
||||||
|
@ -68,9 +64,6 @@ public class NamingStrategyTest extends BaseUnitTestCase {
|
||||||
MetadataImplementor metadata = (MetadataImplementor) metadataSources.getMetadataBuilder()
|
MetadataImplementor metadata = (MetadataImplementor) metadataSources.getMetadataBuilder()
|
||||||
.with( EJB3NamingStrategy.INSTANCE )
|
.with( EJB3NamingStrategy.INSTANCE )
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// todo : naming strategy is not applied
|
|
||||||
|
|
||||||
assertNotNull( SchemaUtil.getTable( "A_ADDRESS", metadata ) );
|
assertNotNull( SchemaUtil.getTable( "A_ADDRESS", metadata ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue