Beginner |
|
Joined: Thu Oct 05, 2006 4:00 pm Posts: 22
|
hi, I have a very simple code snippet.
public List<Order> findAll() {
try {
List<Order> retList = getHibernateTemplate().find("From Order");
if (retList != null && !retList.isEmpty()) {
for (Order order: retList) {
getHibernateTemplate().initialize(order.getLines());
}
}
return retList;
} catch (RuntimeException re) {
throw re;
}
}
It keeps failing at
getHibernateTemplate().initialize(order.getLines());
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
I set lazy="true" (by default) at Lines Set in Order. I am using Spring servlet to wire the DAO into my service object. If I remove initialize() line, it's ok as long as I don't access Lines set. Any thought?
Thanks.
|
|