Having a model like:
@Entity(name = "EntityA")
public class EntityA {
@EmbeddedId
private EntityId id;
@ElementCollection
public Set<EmbeddableA> elementCollection = new HashSet<>();
}
@Entity(name = "EntityB")
public class EntityB {
@Id
private Long id;
}
@Embeddable
public class EntityId implements Serializable {
private String id1;
@ManyToOne
@MapsId
private EntityB id2;
}
@Embeddable
public class EmbeddableA {
private String name;
}
Trying to access element collection:
EntityA a = entityManager.find( EntityA.class, ENTITY_A_ID );
a.elementCollection.size();
Leads to:
I will submit a reproducer. Most likely the same/similar problem as in (https://hibernate.atlassian.net/browse/HHH-16286 ), but since there was no test case in the original issue, I’m opening this one. |