On a mapped collection it seems fetch="join" ignores the lazy property and does indeed initialize the collection when the parent object is created.
For instance (on Hibernate 3.1.3):
mapping:
Code:
<class name="Parent">
..
<set name="children" inverse="true" fetch="join" lazy="true">
..
DAO (via spring):
Code:
return (Parent) getHibernateTemplate().get(Parent.class, new Long(id));
The resulting query is:
Code:
..
FROM Parent LEFT OUTER JOIN child child1_ ON etc. etc.
..
Now it shouldn't fetch the child by default, only when I access the property in the session right? The problem isn't performance but later on in the same session I get a
Code:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
is this a bug or am I overlooking something?