JPA2.0 Lazy Load collection(one-Many) attribute and retriving after em.close()
posted 4 years ago
Is there a way to lazy load a collection attribute in an entity and retrivie it after calling entityManager.close().Which i mean retrival out of the entity manager context.
Am using Hibernate flavor of JPA which is of version 3.6.8
Code template might look like this
EntityManager em = (retrive from factory)
SampleEntity se = em.find(SampelEntity.class,45);
se.getXXXCollection() - Here i required a lazy loading to happen out of the enity manager context
It would ideally throw a "failed to lazily initialize a collection" exception but thought of getting some suggestions from the forum whether is there any solution.
Does anyone implemented @proxy concept of hiberante to override the proxies generated by hibernate during lazy loading of collections?Can i be able to achieve out of context lazy loading by my own implementation of proxies? Not sure what am asking is right.Please suggest