Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>I am using ExtendedPerssisteenceContext as My Entities contain child Entity Collections of Lazy Loading type.</p> </blockquote> <p>This is not a good reason to use <code>EXTENDED</code>. I would suggest you to make it <code>default</code>, which is <code>TRANSACTION</code>. And it's good to make your <code>EntityManager</code> request-scoped, or method-scoped, in non-enterprise environment or when using application-managed persistence, as this is not a very heavy object to create. Moreover, neither using application-scoped EntityManager is a good idea, as it is not threadsafe. </p> <p>Having said that, as you are using JBoss, you should let the container handle the lifecycle of <code>EntityManager</code>, in case you are using JTA. Hence, just inject that with everything <code>default</code></p> <p><strong>Note:</strong></p> <p>Only stateful session beans can have a container-managed, extended entity manager.</p> <p><strong>Links:</strong></p> <ul> <li><a href="http://javanotepad.blogspot.com/2007/08/managing-jpa-entitymanager-lifecycle.html" rel="nofollow noreferrer">http://javanotepad.blogspot.com/2007/08/managing-jpa-entitymanager-lifecycle.html</a></li> <li><a href="https://blogs.oracle.com/enterprisetechtips/entry/extended_persistence_context_in_stateful" rel="nofollow noreferrer">https://blogs.oracle.com/enterprisetechtips/entry/extended_persistence_context_in_stateful</a></li> </ul> <p><strong>Suggestions:</strong></p> <p>Your business method should know whether to load the children or not. But that's the ideal case. A number of times we can't say that and completely depends on the user input -- we can't predict that well. Therefore, there are two solutions available, </p> <ol> <li>make a separate AJAX call to load children </li> <li>Use the filter called open-session-in-view. I would prefer the former.</li> </ol> <p><strong>Links:</strong></p> <ul> <li><a href="https://community.jboss.org/wiki/OpenSessionInView" rel="nofollow noreferrer">https://community.jboss.org/wiki/OpenSessionInView</a></li> <li><a href="http://static.springsource.org/spring/docs/1.2.9/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.html" rel="nofollow noreferrer">http://static.springsource.org/spring/docs/1.2.9/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.html</a></li> <li><a href="https://stackoverflow.com/questions/1103363/why-is-hibernate-open-session-in-view-considered-a-bad-practice">Why is Hibernate Open Session in View considered a bad practice?</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload