HHH-9281 : Table name generated for @ElementCollection uses owning entity class name instead of mapped entity name
(cherry picked from commit ccffe0dea9
)
Conflicts:
hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
This commit is contained in:
parent
7fd71efd04
commit
bc37d5f6b2
|
@ -1187,7 +1187,7 @@ public abstract class CollectionBinder {
|
|||
if ( StringHelper.isEmpty( associationTableBinder.getName() ) ) {
|
||||
//default value
|
||||
associationTableBinder.setDefaultName(
|
||||
collValue.getOwner().getEntityName(),
|
||||
collValue.getOwner().getJpaEntityName(),
|
||||
mappings.getLogicalTableName( collValue.getOwner().getTable() ),
|
||||
collectionEntity != null ? collectionEntity.getEntityName() : null,
|
||||
collectionEntity != null ? mappings.getLogicalTableName( collectionEntity.getTable() ) : null,
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
|
|||
import org.hibernate.metamodel.spi.relational.TableSpecification;
|
||||
import org.hibernate.test.annotations.Country;
|
||||
import org.hibernate.test.util.SchemaUtil;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -259,6 +260,13 @@ public class CollectionElementTest extends BaseCoreFunctionalTestCase {
|
|||
isCollectionColumnPresent( Boy.class.getName(), "hatedNames", "Boy_id" );
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel( jiraKey = "HHH-9281" )
|
||||
public void testDefaultTableNameUsesJpaEntityName() {
|
||||
final TableSpecification table = getCollectionTable( Matrix.class.getName(), "mvalues");
|
||||
assertEquals( "Mtx_mvalues", table.getLogicalName().getText() );
|
||||
}
|
||||
|
||||
private void isLegacyValueCollectionColumnPresent(String collectionHolder, String propertyName) {
|
||||
|
||||
}
|
||||
|
@ -268,14 +276,19 @@ public class CollectionElementTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
private void isCollectionColumnPresent(String collectionOwner, String propertyName, String columnName) {
|
||||
final EntityBinding entityBinding = metadata().getEntityBinding( collectionOwner );
|
||||
final PluralAttributeBinding binding = (PluralAttributeBinding) entityBinding.locateAttributeBinding( propertyName );
|
||||
final TableSpecification table = binding.getPluralAttributeKeyBinding().getCollectionTable();
|
||||
final TableSpecification table = getCollectionTable( collectionOwner, propertyName );
|
||||
|
||||
boolean hasColumn = table.locateColumn( propertyName ) != null;
|
||||
assertTrue( "Could not find " + columnName, hasColumn );
|
||||
}
|
||||
|
||||
private TableSpecification getCollectionTable(String collectionOwner, String propertyName) {
|
||||
final EntityBinding entityBinding = metadata().getEntityBinding( collectionOwner );
|
||||
final PluralAttributeBinding binding = (PluralAttributeBinding) entityBinding.locateAttributeBinding( propertyName );
|
||||
return binding.getPluralAttributeKeyBinding().getCollectionTable();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.hibernate.annotations.Type;
|
|||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@Entity(name="Mtx")
|
||||
public class Matrix {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
Loading…
Reference in New Issue