HHH-12332 - Test and fix for unrelated same named singular attributes in subtypes

This commit is contained in:
Christian Beikov 2018-03-07 13:34:21 +01:00 committed by Andrea Boriero
parent f2d77a033e
commit a9a26087bb
2 changed files with 8 additions and 0 deletions

View File

@ -250,6 +250,10 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
PersistentClass otherClass = metadata.getEntityBinding( entityType2.getAssociatedEntityName() );
PersistentClass commonClass = getCommonPersistentClass( thisClass, otherClass );
if ( commonClass == null ) {
return null;
}
// Create a copy of the type but with the common class
if ( entityType1 instanceof ManyToOneType ) {
ManyToOneType t = (ManyToOneType) entityType1;

View File

@ -104,12 +104,16 @@ public class JoinedInheritanceTest extends BaseCoreFunctionalTestCase {
public static class EntityA extends BaseEntity {
@OneToMany(fetch = FetchType.LAZY)
private Set<EntityC> attributes;
@ManyToOne(fetch = FetchType.LAZY)
private EntityC relation;
}
@Entity(name = "EntityB")
public static class EntityB extends BaseEntity {
@OneToMany(fetch = FetchType.LAZY)
private Set<EntityD> attributes;
@ManyToOne(fetch = FetchType.LAZY)
private EntityD relation;
}
@Entity(name = "EntityC")