<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
EJB3/JPA 2.0 support for AS-7
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/smarlow%40redhat.com">Scott Marlow</a> in <i>JBoss AS7 Development</i> - <a href="http://community.jboss.org/docs/DOC-16271">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p style="margin-bottom: 0in;">This is about how the AS-7 JPA layer and related concerns. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ol><li><p style="margin-bottom: 0in;">Container-managed persistence      context</p><ol><li><p style="margin-bottom: 0in;">Transaction scope (JPA 7.6.1)</p><ol><li><p style="margin-bottom: 0in;">Transaction active invocation</p><ol><li><p style="margin-bottom: 0in;">Persistence context is created                     if none already associated with transaction</p></li><li><p style="margin-bottom: 0in;">Created persistence context                     ends when transaction ends</p></li><li><p style="margin-bottom: 0in;">An extended persistence context                     can also be used, which survives when transaction ends.</p></li></ol> </li><li><p style="margin-bottom: 0in;">No transaction invocation</p><ol><li><p style="margin-bottom: 0in;">Loaded entities are detached at                     end of method call.</p></li></ol> </li></ol> </li><li><p style="margin-bottom: 0in;">Extended scope (JPA 7.6.2)</p><ol><li><p style="margin-bottom: 0in;">Only supported for stateful                session beans.</p></li><li><p style="margin-bottom: 0in;">Entity modifications can be made                outside of a transaction and are applied on the next joined                transaction (anywhere on the cluster).</p></li><li><p style="margin-bottom: 0in;">Extended persistence context                (XPC) is created when stateful bean that depends on a XPC is                created.</p></li><li><p style="margin-bottom: 0in;">XPC is closed when dependent                session bean(s) are closed (via @remove method).</p></li><li><p style="margin-bottom: 0in;">Inheritance</p><ol><li><p style="margin-bottom: 0in;">Stateful beans that create                     other (local) stateful beans, share the same XPC.</p></li></ol> </li></ol> </li><li><p style="margin-bottom: 0in;">Persistence context propagation           (JPA 7.6.3)</p><ol><li><p style="margin-bottom: 0in;">A persistence context will be                propagated to multiple entity managers (instances) within the same                local transaction.</p></li><li><p style="margin-bottom: 0in;">Remote invocations do not                propagate the persistence context.</p></li></ol> </li><li><p style="margin-bottom: 0in;">Persistence context propagation           requirements for component invocations (JPA 7.6.3.1)</p><ol><li><p style="margin-bottom: 0in;">no propagation if component is                invoked without a JTA transaction or without the JTA transaction                propagating:</p><ol><li><p style="margin-bottom: 0in;">Transaction scoped entity                     manager used within the invoked component, will create a new                     persistence context.</p></li><li><p style="margin-bottom: 0in;">Extended scoped entity manager                     used within the invoked component, will use the XPC already bound                     to the (invoked stateful) bean.</p></li><li><p style="margin-bottom: 0in;">If the entity manager is                     invoked within a JTA transaction, the persistence context is                     bound to the JTA transaction.</p></li></ol> </li><li><p style="margin-bottom: 0in;">If a component is invoked and                the JTA transaction is propagated into the component:</p><ol><li><p style="margin-bottom: 0in;">If (SFSB) component has a XPC                     and the transaction already has a different persistence context                     associated with it, an EJBException is thrown by the container.</p></li><li><p style="margin-bottom: 0in;">If a persistence context is                     bound to the JTA transaction, it is propagated into any entity                     managers used in the invocation.</p></li></ol> </li></ol> </li></ol> </li><li><p style="margin-bottom: 0in;">Container requirements review</p><ol><li><p style="margin-bottom: 0in;">Application-managed persistence           context (JPA 7.8.1)</p><ol><li><p style="margin-bottom: 0in;">Container needs to inject entity                manager factory into jndi for application use.</p></li><li><p style="margin-bottom: 0in;">Must use                PersistenceProvider.createContainerEntityManagerFactory method for                3<sup>rd</sup> party support.  Internal APIs are fine for our                persistence provider.</p></li><li><p style="margin-bottom: 0in;">Must use                EntityManagerFactory.close method to close the entity manager                factory prior to shutdown (again for 3<sup>rd</sup> party                support).</p></li></ol> </li><li><p style="margin-bottom: 0in;">Container-managed persistence           context (JPA 7.9.1)</p><ol><li><p style="margin-bottom: 0in;">For 3<sup>rd</sup> party                support, use EntityManagerFactory.createEntityManager .  Consider                using  for our persistence provider as well.</p></li><li><p style="margin-bottom: 0in;">May pass (<code class="western"><span style="font-size: 10pt;"><a class="jive-link-external-small" href="http://download.oracle.com/javaee/6/api/javax/persistence/PersistenceProperty.html">PersistenceProperty</a>[]</span></code>)                PersistenceContext.properties to                EntityManagerFactory.createEntityManager(Map map) .</p></li><li><p style="margin-bottom: 0in;">Container EM wrapper could                implement some EntityManager.unwrap(Class<T> cls) calls but                should default to underlying EM for unhandled classes.</p></li></ol> </li></ol> </li><li><p style="margin-bottom: 0in;">Deployment</p><ol><li><p style="margin-bottom: 0in;">Extract persistence metadata from           persistence.xml</p></li><li><p style="margin-bottom: 0in;">Determine the           PersistenceProvider  classname for each persistence unit (PU).  The           default class is currently org.hibernate.ejb.HibernatePersistence.</p></li><li><p style="margin-bottom: 0in;">Invoke the           PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnitInfo,           Map) to create the EMF that will be used to create all           EntityManager's for the PU.  The properties read from the PU are           passed as the second parameter.</p></li><li><p style="margin-bottom: 0in;">Also pass the           “javax.persistence.validation.factory ” property if validation           mode is not set to NONE.  The validator factory value appears to be           org.hibernate.validator.engine.ValidatorFactoryImpl.  Consult           ValidatorFactoryProvider which is currently used to bootstrap the           validator factory in AS6.</p></li><li><p style="margin-bottom: 0in;">The PU classes shouldn't be           loaded until after the EMF is created.</p></li><li><p style="margin-bottom: 0in;">The EntityManagerFactory is           closed at undeploy time, which also closes all EntityManager's           opened by each factory.</p></li><li><p style="margin-bottom: 0in;">Switchboard changes for PU +           PC???</p></li></ol> </li><li><p style="margin-bottom: 0in;">Clustering</p><ol><li><p style="margin-bottom: 0in;">Determine impact on           <a class="" href="http://community.jboss.org/docs/DOC-13822">http://community.jboss.org/wiki/OptimizingentityandXPCreplication</a> which may need to be tweaked for clustering other persistence           providers.  Judging by the jira status, this optimization is not in           place yet (although the Hibernate persistence provider jira           HHH-2762 is done).</p></li><li><p style="margin-bottom: 0in;">Determine impact on           <a class="" href="http://community.jboss.org/docs/DOC-9565">http://community.jboss.org/wiki/DevEJB3NewSFSBCache</a> (consider support for other persistence providers).</p></li></ol> </li><li><p style="margin-bottom: 0in;">Weld integration      (JpaInjectionServices implementation is wired in at boot time)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></li></ol></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-16271">going to Community</a></p>
        <p style="margin: 0;">Create a new document in JBoss AS7 Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>