You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by bu...@apache.org on 2016/11/23 14:20:00 UTC

svn commit: r1001529 - in /websites/production/tapestry/content: cache/main.pageCache hibernate.html integrating-with-jpa.html

Author: buildbot
Date: Wed Nov 23 14:20:00 2016
New Revision: 1001529

Log:
Production update by buildbot for tapestry

Modified:
    websites/production/tapestry/content/cache/main.pageCache
    websites/production/tapestry/content/hibernate.html
    websites/production/tapestry/content/integrating-with-jpa.html

Modified: websites/production/tapestry/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/tapestry/content/hibernate.html
==============================================================================
--- websites/production/tapestry/content/hibernate.html (original)
+++ websites/production/tapestry/content/hibernate.html Wed Nov 23 14:20:00 2016
@@ -54,7 +54,7 @@
       </div>
 
       <div id="content">
-                <div id="ConfluenceContent"><p>The <strong>Tapestry-Hibernate Integration Library</strong> provides out-of-the-box support for using Hibernate 3 as the back end for normal CRUD style Tapestry applications.</p><div class="aui-label" style="float:right" title="Related Articles"><h3>Related Articles</h3><ul class="content-by-label"><li> 
+                <div id="ConfluenceContent"><p>The <strong>Tapestry-hibernate </strong>module provides out-of-the-box support for using Hibernate 3 as the back end for normal CRUD style Tapestry applications.</p><div class="aui-label" style="float:right" title="Related Articles"><h3>Related Articles</h3><ul class="content-by-label"><li> 
   <div> 
    <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span> 
   </div> 
@@ -96,7 +96,7 @@
   </div> 
   <div class="details"> 
    <a  href="hibernate-core.html">Hibernate - Core</a> 
-  </div> </li></ul></div><p>This represents access to the native Hibernate interfaces, exposed in a thread-safe manner, within a <em>session-per-request</em> strategy.</p><p>Note that a number of the more esoteric ideas in Hibernate are not supported, including nested transactions and supporting multiple persistence units.</p><p>The <a  href="hibernate-core.html">tapestry-hibernate-core</a> module allows non-Tapestry applications to access Hibernate.</p><h1 id="Hibernate-LicensingIssues">Licensing Issues</h1><p>Hibernate is licensed under the Lesser GNU Public License. This is more restrictive license than the Apache Software License used by the rest of Tapestry. The restrictions mostly apply to redistributing Hibernate, especially in any altered form, and will likely be irrelevant to the vast majority of users, but you should be aware.</p><p>This library is compiled against version <strong>3.3.1.GA</strong> of Hibernate (and version 3.4.0.GA of hibernate-annotations), but should wo
 rk with more recent versions.</p><h2 id="Hibernate-Notes">Notes</h2><ul><li>Transactions are <em>aborted</em> (not <em>committed</em>) at the end of each request: you must explicitly commit the transaction if changes are to be saved.</li><li>The CommitAfter annotation for component and service methods can commit the transaction automatically after the method is invoked.</li><li><a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/hibernate/HibernateGridDataSource.html">HibernateGridDataSource</a> can be used with the Grid component to support optimized queries against large data sets.</li></ul></div>
+  </div> </li></ul></div><p>This represents access to the native Hibernate interfaces, exposed in a thread-safe manner, within a <em>session-per-request</em> strategy.</p><p>Note that a number of the more esoteric ideas in Hibernate are not supported, including nested transactions and supporting multiple persistence units.</p><p>The <a  href="hibernate-core.html">tapestry-hibernate-core</a> module allows non-web applications to access Hibernate.</p><h1 id="Hibernate-LicensingIssues">Licensing Issues</h1><p>Hibernate is licensed under the Lesser GNU Public License. This is more restrictive license than the Apache Software License used by the rest of Tapestry. The restrictions mostly apply to redistributing Hibernate, especially in any altered form, and will likely be irrelevant to the vast majority of users, but you should be aware.</p><p>This library is compiled against version <strong>3.3.1.GA</strong> of Hibernate (and version 3.4.0.GA of hibernate-annotations), but should work wi
 th more recent versions.</p><h2 id="Hibernate-Notes">Notes</h2><ul><li>Transactions are <em>aborted</em> (not <em>committed</em>) at the end of each request: you must explicitly commit the transaction if changes are to be saved.</li><li>The CommitAfter annotation for component and service methods can commit the transaction automatically after the method is invoked.</li><li><a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/hibernate/HibernateGridDataSource.html">HibernateGridDataSource</a> can be used with the Grid component to support optimized queries against large data sets.</li></ul></div>
       </div>
 
       <div class="clearer"></div>

Modified: websites/production/tapestry/content/integrating-with-jpa.html
==============================================================================
--- websites/production/tapestry/content/integrating-with-jpa.html (original)
+++ websites/production/tapestry/content/integrating-with-jpa.html Wed Nov 23 14:20:00 2016
@@ -67,18 +67,45 @@
 
 <div class="confluence-information-macro confluence-information-macro-information"><p class="title">Added in 5.3</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body">
 </div></div>
-<div style="border-right: 20px solid #D8E4F1;border-left: 20px solid #D8E4F1;"><p>&#160;</p></div><p>Starting with Tapestry 5.3, Tapestry provides built-in integration with the Java Persistence API (JPA). This module supersedes <a  class="external-link" href="http://tynamo.org/tapestry-jpa+guide" rel="nofollow">Tynamo's JPA integration</a>.</p><p><strong>Contents</strong></p><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1478607656517 {padding: 0px;}
-div.rbtoc1478607656517 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1478607656517 li {margin-left: 0px;padding-left: 0px;}
-
-/*]]>*/</style></p><div class="toc-macro rbtoc1478607656517">
-<ul class="toc-indentation"><li><a  href="#IntegratingwithJPA-ConfiguringJPA">Configuring JPA</a>
-<ul class="toc-indentation"><li><a  href="#IntegratingwithJPA-XML-lessJPAconfiguration">XML-less JPA configuration</a></li><li><a  href="#IntegratingwithJPA-Automaticallyaddingmanagedclasses">Automatically adding managed classes</a></li></ul>
+<div style="border-right: 20px solid #D8E4F1;border-left: 20px solid #D8E4F1;"><p>&#160;</p></div><p>Starting with Tapestry 5.3, Tapestry provides built-in integration with the Java Persistence API (JPA) through the <strong>Tapestry-jpa</strong> module. This module supersedes the <a  class="external-link" href="http://www.tynamo.org/tapestry-jpa+guide/" rel="nofollow">Tynamo JPA module</a>.</p><p><strong>Contents</strong></p><p><style type="text/css">/*<![CDATA[*/
+div.rbtoc1479910788609 {padding: 0px;}
+div.rbtoc1479910788609 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1479910788609 li {margin-left: 0px;padding-left: 0px;}
+
+/*]]>*/</style></p><div class="toc-macro rbtoc1479910788609">
+<ul class="toc-indentation"><li><a  href="#IntegratingwithJPA-Downloading">Downloading</a>
+<ul class="toc-indentation"><li><a  href="#IntegratingwithJPA-SelectingaJPAImplementation">Selecting a JPA Implementation</a></li></ul>
+</li><li><a  href="#IntegratingwithJPA-ConfiguringJPA">Configuring JPA</a>
+<ul class="toc-indentation"><li><a  href="#IntegratingwithJPA-XML-lessJPAconfiguration">XML-less JPA configuration</a></li><li><a  href="#IntegratingwithJPA-Automaticallyaddingmanagedclasses">Automatically adding managed classes</a></li><li><a  href="#IntegratingwithJPA-ConfigurationSettings">Configuration Settings</a></li></ul>
 </li><li><a  href="#IntegratingwithJPA-InjectingtheEntityManager">Injecting the EntityManager</a>
 <ul class="toc-indentation"><li><a  href="#IntegratingwithJPA-InjectingtheEntityManagerintopageandcomponentclasses">Injecting the EntityManager into page and component classes</a></li><li><a  href="#IntegratingwithJPA-InjectingEntityManagerintoservices">Injecting EntityManager into services</a></li></ul>
 </li><li><a  href="#IntegratingwithJPA-Transactionmanagement">Transaction management</a></li></ul>
-</div><h1 id="IntegratingwithJPA-ConfiguringJPA">Configuring JPA</h1><p>The persistence.xml file is the standard configuration file in JPA used to define the persistence units. Tapestry reads this file to create the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityManagerFactory.html" rel="nofollow">EntityManagerFactory</a>. The following example demonstrates a persistence.xml file.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div><h1 id="IntegratingwithJPA-Downloading">Downloading</h1><p>The<strong> Tapestry-jpa</strong> module is not automatically included in Tapestry applications because of the additional dependencies it requires. If you're using Maven, just add the <code>tapestry-jpa</code> dependency to your application's pom.xml file, something like this:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>pom.xml (partial)</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;dependency&gt;
+    &lt;groupId&gt;org.apache.tapestry&lt;/groupId&gt;
+    &lt;artifactId&gt;tapestry-jpa&lt;/artifactId&gt;
+    &lt;version&gt;${tapestry-version}&lt;/version&gt;
+&lt;/dependency&gt;</pre>
+</div></div><p>If you aren't using Maven (or Gradle, Ivy, etc), you'll have to download the jar and its dependencies yourself.</p><h2 id="IntegratingwithJPA-SelectingaJPAImplementation">Selecting a JPA Implementation</h2><p>The Tapestry-jpa module includes a dependency on a JPA specification (API) from Geronimo but not an implementation. You'll have to chose a JPA implementation, such as EclipseLink or Hibernate. The Tapestry-jpa module assumes you'll use Eclipselink. You just have to add the EclipseLink dependency:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>pom.xml (partial) for EclipseLink</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;dependency&gt;
+    &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
+    &lt;artifactId&gt;eclipselink&lt;/artifactId&gt;
+    &lt;version&gt;${eclipselink-version}&lt;/version&gt;
+&lt;/dependency&gt;</pre>
+</div></div><p>Or, if you'd rather use Hibernate as your JPA implementation, you'll want to exclude either the Gernonimo or Hibernate JPA specification JAR:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>pom.xml (partial) for Hibernate</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;dependency&gt;
+    &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
+    &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
+    &lt;version&gt;${hibernate-version}&lt;/version&gt;
+    &lt;exclusions&gt;
+        &lt;exclusion&gt;
+            &lt;!-- omit Geronimo JPA spec to avoid conflict with Hibernate JPA spec --&gt;
+            &lt;groupId&gt;org.apache.geronimo.specs&lt;/groupId&gt;
+            &lt;artifactId&gt;geronimo-jpa_2.0_spec&lt;/artifactId&gt;
+        &lt;/exclusion&gt;
+    &lt;/exclusions&gt;
+&lt;/dependency&gt;</pre>
+</div></div><h1 id="IntegratingwithJPA-ConfiguringJPA">Configuring JPA</h1><p>The <strong>persistence.xml</strong> file is the standard configuration file in JPA used to define the persistence units. Tapestry reads this file to create the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityManagerFactory.html" rel="nofollow">EntityManagerFactory</a>. The following example demonstrates a persistence.xml file.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>persistence.xml</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
 &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"&gt;
    &lt;persistence-unit name="DemoUnit" transaction-type="RESOURCE_LOCAL"&gt;
@@ -102,43 +129,35 @@ div.rbtoc1478607656517 li {margin-left:
     }
 
 }</pre>
-</div></div><h2 id="IntegratingwithJPA-XML-lessJPAconfiguration">XML-less JPA configuration</h2><p>With Tapestry, configuring JPA is much simpler than as described in the JPA specification. Tapestry allows you to configure the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityManagerFactory.html" rel="nofollow">EntityManagerFactory</a> programmatically, without writing any XML. Imagine you want to use JDBC connections managed by the container and provided through JNDI. The resulting persistence descriptor might look like this:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h2 id="IntegratingwithJPA-XML-lessJPAconfiguration">XML-less JPA configuration</h2><p>With Tapestry, configuring JPA can be much simpler than described by the JPA specification. Tapestry allows you to configure the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityManagerFactory.html" rel="nofollow">EntityManagerFactory</a> programmatically, without writing any XML. For example, imagine that you want to use JDBC connections managed by the container and provided through JNDI. The resulting persistence descriptor might look like this:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>persistence.xml</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
 &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
              version="2.0"&gt;
    &lt;persistence-unit name="JTAUnit" transaction-type="RESOURCE_LOCAL"&gt;
-
-      &lt;non-jta-data-source&gt;
-         jdbc/JPATest
-      &lt;/non-jta-data-source&gt;
-
+      &lt;non-jta-data-source&gt;jdbc/JPATest&lt;/non-jta-data-source&gt;
       &lt;properties&gt;
          &lt;property name="eclipselink.ddl-generation" value="create-tables"/&gt;
          &lt;property name="eclipselink.logging.level" value="fine"/&gt;
       &lt;/properties&gt;
    &lt;/persistence-unit&gt;
-
 &lt;/persistence&gt;</pre>
-</div></div><p>Now let's see how to provide the same configuration <em>without</em> XML. The following demonstrates an equivalent JPA configuration.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Now let's see how to provide the same configuration <em>without</em> XML. The following demonstrates an equivalent JPA configuration.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>AppModule.java (partial)</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class AppModule {
 
    @Contribute(EntityManagerSource.class)
    public static void configurePersistenceUnitInfos(MappedConfiguration&lt;String,PersistenceUnitConfigurer&gt; cfg) {
 
       PersistenceUnitConfigurer configurer = new PersistenceUnitConfigurer() {
-
          public void configure(TapestryPersistenceUnitInfo unitInfo) {
-
             unitInfo.nonJtaDataSource("jdbc/JPATest")
                .addProperty("eclipselink.ddl-generation", "create-tables")
                .addProperty("eclipselink.logging.level", "fine");
          }
      };
-
      cfg.add("JTAUnit", configurer);
    }
 }</pre>
-</div></div><p>In the example above you can see a contribution to the <em>EntityManagerSource</em> service. This service is responsible for creating the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityManagerFactory.html" rel="nofollow">EntityManagerFactory</a> to be used to create <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityManager.html" rel="nofollow">EntityManager</a>. When the service is initialized, it parses the <em>persistence.xml</em> file, if available. For any persistence unit defined in the XML descriptor a <em>TapestryPersistenceUnitInfo</em> object is created. The <em>TapestryPersistenceUnitInfo</em> interface is a mutable extension of the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/spi/PersistenceUnitInfo.html" rel="nofollow">PersistenceUnitInfo</a> interface (defined in the JPA specification) that allows you to configure a p
 ersistence unit programmatically.</p><p>After parsing the persistence descriptor, the EntityManagerSource service applies its configuration to create further persistence units and/or update the existing ones. The service&#8217;s configuration is a map in which persistence unit names are associated with <em>PersistenceUnitConfigurer</em> instances. A PersistenceUnitConfigurer is used to configure a persistence unit programmatically that has been associated with it. In the example above you can see a contribution providing a PersistenceUnitConfigurer for the unit named <em>JTAUnit</em>.</p><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Note that the TapestryPersistenceUnitInfo instance passed to the PersistenceUnitConfigurer is either empty or my contain the persistence unit metadata read from the persist
 ence.xml file. What happens if you contribute a PersistenceUnitConfigurer for a persistence unit that has not been defined in the persistence.xml file? In this case Tapestry assumes that you want to configure the persistence unit programmatically and just creates a fresh <em>TapestryPersistenceUnitInfo</em> object and passes it to the <em>PersistenceUnitConfigurer</em>.</p></div></div><h2 id="IntegratingwithJPA-Automaticallyaddingmanagedclasses">Automatically adding managed classes</h2><p>If only a single persistence unit is defined, Tapestry scans the <em>application-root-package.entities</em> package. The classes in that package are automatically added as managed classes to the defined persistence unit.</p><p>If you have additional packages containing entities, you may contribute them to the <em>JpaEntityPackageManager</em> service configuration.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>In the example above you can see a contribution to the <em>EntityManagerSource</em> service. This service is responsible for creating the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityManagerFactory.html" rel="nofollow">EntityManagerFactory</a> to be used to create <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityManager.html" rel="nofollow">EntityManager</a>. When the service is initialized, it parses the <em>persistence.xml</em> file, if available. For any persistence unit defined in the XML descriptor a <em>TapestryPersistenceUnitInfo</em> object is created. The <em>TapestryPersistenceUnitInfo</em> interface is a mutable extension of the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/spi/PersistenceUnitInfo.html" rel="nofollow">PersistenceUnitInfo</a> interface (defined in the JPA specification) that allows you to configure a p
 ersistence unit programmatically.</p><p>After parsing the persistence descriptor, the EntityManagerSource service applies its configuration to create further persistence units and/or update the existing ones. The service&#8217;s configuration is a map in which persistence unit names are associated with <em>PersistenceUnitConfigurer</em> instances. A PersistenceUnitConfigurer is used to configure a persistence unit programmatically that has been associated with it. In the example above you can see a contribution providing a PersistenceUnitConfigurer for the unit named <em>JTAUnit</em>.</p><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Note that the TapestryPersistenceUnitInfo instance passed to the PersistenceUnitConfigurer is either empty or my contain the persistence unit metadata read from the persist
 ence.xml file. What happens if you contribute a PersistenceUnitConfigurer for a persistence unit that has not been defined in the persistence.xml file? In this case Tapestry assumes that you want to configure the persistence unit programmatically and just creates a fresh <em>TapestryPersistenceUnitInfo</em> object and passes it to the <em>PersistenceUnitConfigurer</em>.</p></div></div><h2 id="IntegratingwithJPA-Automaticallyaddingmanagedclasses">Automatically adding managed classes</h2><p>If only a single persistence unit is defined, Tapestry scans the <em>application-root-package.entities</em> package. The classes in that package are automatically added as managed classes to the defined persistence unit.</p><p>If you have additional packages containing entities, you may contribute them to the <em>JpaEntityPackageManager</em> service configuration.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>A
 ppModule.java (partial)</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class AppModule {
 
    @Contribute(JpaEntityPackageManager.class)
@@ -148,10 +167,10 @@ div.rbtoc1478607656517 li {margin-left:
       configuration.add("com.acme.model");
    }
 }</pre>
-</div></div><p>As you can see, you may add as many packages as you wish.</p><h1 id="IntegratingwithJPA-InjectingtheEntityManager">Injecting the EntityManager</h1><p>The created entity managers can be injected into page, component and other services.</p><h2 id="IntegratingwithJPA-InjectingtheEntityManagerintopageandcomponentclasses">Injecting the EntityManager into page and component classes</h2><p>Depending on whether more than one persistence unit has been defined, the way to inject <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityManager.html" rel="nofollow">EntityManager</a> varies slightly. Let&#8217;s start with a simple scenario, where only a single persistence unit is defined. In this case, an EntityManager can be injected using the @Inject annotation.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>As you can see, you may add as many packages as you wish.</p><h2 id="IntegratingwithJPA-ConfigurationSettings">Configuration Settings</h2><p>The following can be configured in your application module (usually AppModule.java), just like other Tapestry <a  href="configuration.html">configuration symbols</a>.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Symbol</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">JpaSymbols.PROVIDE_ENTITY_VALUE_ENCODERS</td><td colspan="1" rowspan="1" class="confluenceTd">true</td><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">JpaSymbols.EARLY_START_UP</td><td colspan="1" rowspan="1" class="confluenceTd">true</td><td colspan="1" rowspan="1" class="confluenceTd">&#1
 60;</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">JpaSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED</td><td colspan="1" rowspan="1" class="confluenceTd">true</td><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">JpaSymbols.PERSISTENCE_DESCRIPTOR</td><td colspan="1" rowspan="1" class="confluenceTd">/META-INF/persistence.xml</td><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td></tr></tbody></table></div><p>&#160;</p><h1 id="IntegratingwithJPA-InjectingtheEntityManager">Injecting the EntityManager</h1><p>The created entity managers can be injected into page, component and other services.</p><h2 id="IntegratingwithJPA-InjectingtheEntityManagerintopageandcomponentclasses">Injecting the EntityManager into page and component classes</h2><p>Depending on whether more than one persistence unit has been defined, the way to inject <a  class="external-link" href="http://download.oracle.com/j
 avaee/6/api/javax/persistence/EntityManager.html" rel="nofollow">EntityManager</a> varies slightly. Let&#8217;s start with a simple scenario, where only a single persistence unit is defined. In this case, an EntityManager can be injected using the @<a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/PersistenceContext.html" rel="nofollow">PersistenceContext</a> annotation.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>CreateAddress.java</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class CreateAddress {
 
-   @Inject
+   @PersistenceContext
    private EntityManager entityManager;
 
    @Property
@@ -162,10 +181,10 @@ div.rbtoc1478607656517 li {margin-left:
       entityManager.persist(address);
    }
 }</pre>
-</div></div><p>Alternatively, you can use the @<a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/PersistenceContext.html" rel="nofollow">PersistenceContext</a> annotation to get the EntityManager injected into a page or component, as shown in the following example.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Alternatively, you can use the @Inject<a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/PersistenceContext.html" rel="nofollow"> annotation to get the EntityManager injected into a page or component, as shown in the following example.</a></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>CreateAddress.java</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class CreateAddress {
 
-   @PersistenceContext
+   @Inject
    private EntityManager entityManager;
 
    @Property
@@ -176,7 +195,7 @@ div.rbtoc1478607656517 li {margin-left:
       entityManager.persist(address);
    }
 }</pre>
-</div></div><p>If you have multiple instances of persistence-unit defined in the same application, you need to explicitly tell Tapestry which persistence unit you want to get injected. This is what the @PersistenceContext annotation&#8217;s <em>name</em> attribute is used for? The following example demonstrates how to inject the persistence unit named <em>DemoUnit</em>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>However, if you have multiple instances of persistence-unit defined in the same application, you need to explicitly tell Tapestry which persistence unit you want to get injected. This is what the @PersistenceContext annotation&#8217;s <em>name</em> attribute is used for? The following example demonstrates how to inject the persistence unit named <em>DemoUnit</em>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>CreateAddress.java</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class CreateAddress {
 
    @PersistenceContext(unitName = "DemoUnit")
@@ -191,34 +210,34 @@ div.rbtoc1478607656517 li {margin-left:
       entityManager.persist(address);
    }
 }</pre>
-</div></div><h2 id="IntegratingwithJPA-InjectingEntityManagerintoservices">Injecting EntityManager into services</h2><p>While component injection occurs only on fields, the injection in the IoC layer may be triggered by a field or a constructor. The following example demonstrates field injection, when a single persistence unit is defined in the persistence descriptor.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class UserDAOImpl implements UserDAO {
+</div></div><h2 id="IntegratingwithJPA-InjectingEntityManagerintoservices">Injecting EntityManager into services</h2><p>While component injection occurs only on fields, the injection in the IoC layer may be triggered by a field or a constructor. The following example demonstrates field injection, when a single persistence unit is defined in the persistence descriptor.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>UserDaoImpl.java</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class UserDaoImpl implements UserDao {
    @Inject
    private EntityManager entityManager;
 
    ...
 }</pre>
-</div></div><p>The constructor injection is demonstrated in the following example.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class UserDAOImpl implements UserDAO {
+</div></div><p>The constructor injection is demonstrated in the following example.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>UserDaoImpl</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class UserDaoImpl implements UserDao {
 
    private EntityManager entityManager;
 
-   public UserDAOImpl(EntityManager entityManager) {
+   public UserDaoImpl(EntityManager entityManager) {
       this.entityManager = entityManager;
    }
 
    ...
 }</pre>
-</div></div><p>If multiple persistence units are defined in the same application, you need to disambiguate the unit to inject. This is done with the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/PersistenceContext.html" rel="nofollow">@PersistenceContext</a> annotation, as shown in the following example. Because @PersistenceContext must not be placed on constructor parameters, you can&#8217;t use constructor injection and must switch to field injection.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class UserDAOImpl implements UserDAO {
+</div></div><p>If multiple persistence units are defined in the same application, you need to disambiguate the unit to inject. This is done with the <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/PersistenceContext.html" rel="nofollow">@PersistenceContext</a> annotation, as shown in the following example. Because @PersistenceContext must not be placed on constructor parameters, you can&#8217;t use constructor injection and must switch to field injection.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>UserDaoImpl</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class UserDaoImpl implements UserDao {
    @Inject
    @PersistenceContext(unitName = "DemoUnit")
    private EntityManager entityManager;
 
    ...
 }</pre>
-</div></div><h1 id="IntegratingwithJPA-Transactionmanagement">Transaction management</h1><p>As you may already know from the Hibernate integration library, Tapestry automatically manages transactions for you. The JPA integration library defines the @CommitAfter annotation, which acts as the correspondent annotation from the Hibernate integration library. Let&#8217;s explore the <em>UserDAO</em> interface to see the annotation in action.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public interface UserDAO {
+</div></div><h1 id="IntegratingwithJPA-Transactionmanagement">Transaction management</h1><p>As you may already know from the Hibernate integration library, Tapestry automatically manages transactions for you. The JPA integration library defines the @CommitAfter annotation, which acts as the correspondent annotation from the Hibernate integration library. Let&#8217;s explore the <em>UserDao </em>interface to see the annotation in action.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>UserDao.java</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public interface UserDao {
 
    @CommitAfter
    @PersistenceContext(unitName = "DemoUnit")
@@ -230,10 +249,10 @@ div.rbtoc1478607656517 li {margin-left:
    @PersistenceContext(unitName = "DemoUnit")
    void delete(User... users);
 }</pre>
-</div></div><p>As you can see, the annotation may be placed on service method in order to mark that method as transactional. Any method marked with the @CommitAfter annotation will have a transaction started before, and committed after, it is called. Runtime exceptions thrown by by a transactional method will abort the transaction. Checked exceptions are ignored and the transaction will be committed anyway.</p><div class="confluence-information-macro confluence-information-macro-warning"><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Note that <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityTransaction.html" rel="nofollow">EntityTransaction</a> interface does not support two phase commits. Committing transactions of multiple EntityManagers in the same request might result in data consistency issues. That&#8217;s why @CommitAfter annotat
 ion must be accompanied by the @PersistenceContext annotation if multiple persistence unit are defined in an application. This way you can only commit the transaction of a single persistence unit. You should be very carefully, if you are committing multiple transactions manually in the same request.</p></div></div><p>After placing the @CommitAfter annotation on methods, you need to tell Tapestry to advise those methods. This is accomplished by adding the transaction advice, as shown in the following example.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>As you can see, the annotation may be placed on service method in order to mark that method as transactional. Any method marked with the @CommitAfter annotation will have a transaction started before, and committed after, it is called. Runtime exceptions thrown by by a transactional method will abort the transaction. Checked exceptions are ignored and the transaction will be committed anyway.</p><div class="confluence-information-macro confluence-information-macro-warning"><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Note that <a  class="external-link" href="http://download.oracle.com/javaee/6/api/javax/persistence/EntityTransaction.html" rel="nofollow">EntityTransaction</a> interface does not support two phase commits. Committing transactions of multiple EntityManagers in the same request might result in data consistency issues. That&#8217;s why @CommitAfter annotat
 ion must be accompanied by the @PersistenceContext annotation if multiple persistence unit are defined in an application. This way you can only commit the transaction of a single persistence unit. You should be very carefully, if you are committing multiple transactions manually in the same request.</p></div></div><p>After placing the @CommitAfter annotation on methods, you need to tell Tapestry to advise those methods. This is accomplished by adding the transaction advice, as shown in the following example.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>AppModule.java (partial)</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class AppModule {
 
-   @Match("*DAO")
+   @Match("*Dao")
    public static void adviseTransactionally(
          JpaTransactionAdvisor advisor,
          MethodAdviceReceiver receiver) {