We are seeing null collections in Hibernate relationships, and were wondering about the expected behavior for the collections.
So, for example, our members have a relationship to the groups they are in:
Member:
@OneToMany
@JoinTable(
name="GroupMember",
joinColumns=@JoinColumn(name="memberId"),
inverseJoinColumns=@JoinColumn(name="groupTypeId"))
public Set<GroupType> getGroupTypes() {
return groupTypes;
}
We would expect any Member object loaded from Hibernate to have a non null Set<GroupType>, but we are seeing that intermittently, the return Set<GroupType> is null, rather than an empty set.
When we persist the object, we don't bother to initialize those collections if they are empty.
From
http://opensource.atlassian.com/project ... e/HHH-2369, I get the impression that Hibernate should always return an empty collection, per the ejb3 specification. Is this true? Is this true even if second level cache is enabled and Hibernate is reviving a saved object with a null collection? Are there any conditions under which an object loaded from Hibernate will return a null collection?