vendredi 18 septembre 2015

Transaction handling with a container managed EntityManager

A collection needs to be fetched lazily. If I then try to access its components, I get the following Exception :

failed to lazily initialize a collection of role:
 mapp3.model.ProductDefinition, could not initialize proxy - no Session

So I retrieved the session from the entityManager this way:

Session session = entityManager.unwrap(Session.class);

but this causes the following exception :

Error executing command: Transaction management is not available for container managed EntityManagers.

I am using Hibernate inside a Karaf container. How else could I proceed to either be able to browse the lazily fetched collection, either to start a Session with a container managed EntityMananger ?



from Newest questions tagged java - Stack Overflow http://ift.tt/1MuMyyE
via IFTTT

Aucun commentaire:

Enregistrer un commentaire