Hi,
I'm using Spring together with Hibernate for developing a Portlet for the Liferay portal server. I now have basically two entities, A and B, where A possibly contains many B's. So this goes to a one-to-many mapping between the two.
<set cascade="all" lazy="true" name="comments" order-by="creationDate desc">
<key column="lfpn_pinboardentries_idPinboardEntry" not-null="true"/>
<one-to-many class="Comment"/>
</set>
In the corresponding DAO of entity A in the DAO layer, I'm inheriting from "HibernateDaoSupport" provided by spring, and so a typical retrieval of data looks like the following:
...
public A getA(long id) {
return (A) getHibernateTemplate().get(A.class, id);
}
...
Everything works fine if I'm having "lazy=false", but as soon as I'm switching to "lazy=true" it gives me the following error:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.lifepin.entities.PinboardEntry.comments, no session or session was closed
Does anyone have a suggestion what could be the problem or hints how to solve it?
Thanks!