HHH-9280 : Table name generated for @ElementCollection uses owning entity class name instead of mapped entity name

This commit is contained in:
Gail Badner 2014-07-09 15:08:21 -07:00
parent ee0cf672d7
commit ccffe0dea9
3 changed files with 10 additions and 2 deletions

View File

@ -1214,7 +1214,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,

View File

@ -36,6 +36,7 @@ import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Table;
import org.hibernate.test.annotations.Country;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -261,6 +262,13 @@ public class CollectionElementTest extends BaseCoreFunctionalTestCase {
isCollectionColumnPresent( Boy.class.getName(), "hatedNames", "Boy_id" );
}
@Test
public void testDefaultTableNameUsesJpaEntityName() {
final Collection collection = configuration().getCollectionMapping( Matrix.class.getName() + "." + "mvalues" );
final Table table = collection.getCollectionTable();
assertEquals( "Mtx_mvalues", table.getName() );
}
private void isLegacyValueCollectionColumnPresent(String collectionHolder, String propertyName) {
}

View File

@ -17,7 +17,7 @@ import org.hibernate.annotations.Type;
/**
* @author Emmanuel Bernard
*/
@Entity
@Entity(name="Mtx")
public class Matrix {
@Id
@GeneratedValue