I know this error is pretty common but I have searched and nothing seems to work.
I have a recursive relationship in Option entity (childrenOptions, parentOption - as lazy load), and I'm loading a plane list through HQL query like this:
Session session = sessionFactory.openSession();
session.beginTransaction();
List result = session.createQuery("from Option as o").list();
session.getTransaction().commit();
session.close();
return result;
I'm trying to build the user's options tree manually, out of Hibernate session, because it's depend on other Role entities previously loaded.
So, when I try to use getChildrenOptions() property to .add sub-options, I'm getting "could not initialize proxy - no Session" error.
I have already tried session.evict() and .getHibernateLazyInitializer().getImplementation(), but
if (option instanceof HibernateProxy)
is always false.
Is it possible to unable/remove this proxy behaviour and work with collection properties like normal POJO's?
It's seems like a performance issue to eager load all options, I would like to build the tree by myself.
Thanks in advance.