tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r1001535 - in /websites/production/tapestry/content: cache/main.pageCache hibernate-user-guide.html integrating-with-jpa.html
Date Wed, 23 Nov 2016 15:20:01 GMT
Author: buildbot
Date: Wed Nov 23 15:20:01 2016
New Revision: 1001535

Log:
Production update by buildbot for tapestry

Modified:
    websites/production/tapestry/content/cache/main.pageCache
    websites/production/tapestry/content/hibernate-user-guide.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-user-guide.html
==============================================================================
--- websites/production/tapestry/content/hibernate-user-guide.html (original)
+++ websites/production/tapestry/content/hibernate-user-guide.html Wed Nov 23 15:20:01 2016
@@ -64,16 +64,9 @@
       </div>
 
       <div id="content">
-                <div id="ConfluenceContent"><div class="navmenu" style="float:right;
background:#eee; margin:3px; padding:3px">
-<div class="error"><span class="error">Error formatting macro: contentbylabel:
com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not parse cql :
null</span> </div></div> 
-
-<h1 id="HibernateUserGuide-Entityvalueencoding">Entity value encoding</h1>
-
-<p>Value encoders are automatically created for all mapped Hibernate entity types.
This is done by encoding the entity as it's id (coerced to a String) and decoding the entity
by looking it up in the Hibernate Session using the encoded id. Consider 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 ViewPerson
+                <div id="ConfluenceContent"><p><em>This page describes
functionality provided by the Tapestry-hibernate-core module, but the descriptions apply equally
to the Tapestry-jpa module.</em></p><div class="navmenu" style="float:right;
background:#eee; margin:3px; padding:3px">
+<div class="error"><span class="error">Error formatting macro: contentbylabel:
com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not parse cql :
null</span> </div></div><h1 id="HibernateUserGuide-Entityvalueencoding">Entity
value encoding</h1><p>The Tapestry-hibernate-core module provides Value Encoder
automatically for all mapped Hibernate entity types. This is done by encoding the entity as
it's id (coerced to a String) and decoding the entity by looking it up in the Hibernate Session
using the encoded id. Consider 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 ViewPerson
 {
   @Property
   private Person person;
@@ -88,41 +81,22 @@ public class ViewPerson
     return person;
   }
 }</pre>
-</div></div>
-
-<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;">
-&lt;html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"&gt;
+</div></div><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;">&lt;html
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"&gt;
 &lt;body&gt;
   The person's name is: ${person.name}
 &lt;/body&gt;
 &lt;/html&gt;</pre>
-</div></div>
-
-<p>Accessing the page as <strong>/viewperson/152</strong> would load the
Person entity with id 152 and use that as the page context.</p>
-
-<h1 id="HibernateUserGuide-Using@PageActivationContext">Using @PageActivationContext</h1>
-
-<p>If you prefer to use annotations, you may let Tapestry generate the page activation
context handlers for you. Relying on an existing ValueEncoder for the corresponding property
you can use the @PageActivationContext annotation. The disadvantage is that you can't access
the handlers in a unit test.</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 ViewPerson
+</div></div><p>Accessing the page as <strong>/viewperson/152</strong>
would load the Person entity with id 152 and use that as the page context.</p><h1
id="HibernateUserGuide-Using@PageActivationContext">Using @PageActivationContext</h1><p>If
you prefer to use annotations, you may let Tapestry generate the page activation context handlers
for you. Relying on an existing ValueEncoder for the corresponding property you can use the
@PageActivationContext annotation. The disadvantage is that you can't access the handlers
in a unit test.</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 ViewPerson
 {
   @Property
   @PageActivationContext
   private Person person;
   
 }</pre>
-</div></div>
-
-<h1 id="HibernateUserGuide-Using@Persistwithentities">Using @Persist with entities</h1>
-
-<p>If you wish to persist an entity in the session, you may use the "entity" persistence
strategy:</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 ViewPerson
+</div></div><h1 id="HibernateUserGuide-Using@Persistwithentities">Using
@Persist with entities</h1><p>If you wish to persist an entity in the session,
you may use the "entity" persistence strategy:</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 ViewPerson
 {
   @Persist("entity")
   @Property
@@ -134,23 +108,12 @@ public class ViewPerson
   }
   
 }</pre>
-</div></div>
-
-<p>This persistence strategy works with any Hibernate entity that is associated with
a valid Hibernate Session by persisting only the id of the entity. Notice that no onPassivate()
method is needed; when the page renders the entity is loaded by the id stored in the session.</p>
-
-<h1 id="HibernateUserGuide-Using@SessionStatewithentities">Using @SessionState with
entities</h1>
-
+</div></div><p>This persistence strategy works with any Hibernate entity
that is associated with a valid Hibernate Session by persisting only the id of the entity.
Notice that no onPassivate() method is needed; when the page renders the entity is loaded
by the id stored in the session.</p><h1 id="HibernateUserGuide-Using@SessionStatewithentities">Using
@SessionState with entities</h1><p>
 
-
-<div class="confluence-information-macro confluence-information-macro-information"><p
class="title">Added in 5.2</p><span class="aui-icon aui-icon-small aui-iconfont-info
confluence-information-macro-icon"></span><div class="confluence-information-macro-body">
+</p><div class="confluence-information-macro confluence-information-macro-information"><p
class="title">Added in 5.2</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;"></div>
-
-<p>The default strategy for persisting Session State Objects is "session". Storing
a Hibernate entity into a &lt;HttpSession&gt; is problematic because the stored entity
is detached from the Hibernate session. Similar to @Persist("entity") you may use the "entity"
persistence strategy to persist Hibernate entities as SSOs:</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 Index
+<div style="border-right: 20px solid #D8E4F1;border-left: 20px solid #D8E4F1;"><p>&#160;</p></div>The
default strategy for persisting Session State Objects is "session". Storing a Hibernate entity
into a &lt;HttpSession&gt; is problematic because the stored entity is detached from
the Hibernate session. Similar to @Persist("entity") you may use the "entity" persistence
strategy to persist Hibernate entities as SSOs:<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 Index
 {
   @SessionState
   @Property
@@ -160,13 +123,8 @@ public class Index
   
 }
 </pre>
-</div></div>
-
-<p>For this purpose you need to set the value of the symbol &lt;HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED&gt;
to &lt;true&gt;:</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 AppModule
+</div></div><p>For this purpose you need to set the value of the symbol
&lt;HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED&gt; to &lt;true&gt;:</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 AppModule
 {
     public static void contributeApplicationDefaults(MappedConfiguration&lt;String, String&gt;
configuration)
     {
@@ -174,13 +132,8 @@ public class AppModule
     }
 }
 </pre>
-</div></div>
-
-<p>Alternatively you can apply the "entity" persistence strategy to a single Hibernate
entity:</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 AppModule
+</div></div><p>Alternatively you can apply the "entity" persistence strategy
to a single Hibernate entity:</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 AppModule
 {
     public void contributeApplicationStateManager(MappedConfiguration&lt;Class, ApplicationStateContribution&gt;
configuration)
     {
@@ -188,17 +141,8 @@ public class AppModule
     }
 }
 </pre>
-</div></div>
-
-<h1 id="HibernateUserGuide-CommittingChanges">Committing Changes</h1>
-
-<p>All Hibernate operations occur in a transaction, but that transaction is aborted
at the end of each request; thus any changes you make will be <em>lost</em> unless
the transaction is committed.</p>
-
-<p>The correct way to commit the transaction is via the @CommitAfter annotation:</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 EditPerson
+</div></div><h1 id="HibernateUserGuide-CommittingChanges">Committing Changes</h1><p>All
Hibernate operations occur in a transaction, but that transaction is aborted at the end of
each request; thus any changes you make will be <em>lost</em> unless the transaction
is committed.</p><p>The correct way to commit the transaction is via the @CommitAfter
annotation:</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 EditPerson
 {
   @Persist("entity")
   @Property
@@ -220,31 +164,8 @@ public class EditPerson
     return personIndex;
   }
 }</pre>
-</div></div>
-
-<p>In this example, the Person object may be updated by a form; the form's success
event handler method, onSuccess() has the @CommitAfter annotation.</p>
-
-<p>Behind the scenes, the @CommitAfter annotation causes the <a  class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/hibernate/HibernateSessionManager.html">HibernateSessionManager</a>'s
commit() method to be executed before the method returns.</p>
-
-<p>The transaction will be committed when the method completes normally.</p>
-
-<p>The transaction will be <em>aborted</em> if the method throws a RuntimeException.</p>
-
-<p>The transaction will be <strong>committed</strong> if the method throws
a <em>checked</em> exception (one listed in the throws clause of the method).</p>
-
-<h1 id="HibernateUserGuide-ManagingTransactionsusingDAOs">Managing Transactions using
DAOs</h1>
-
-<p>As your application grows, you will likely create a Data Access Object layer between
your pages and the Hibernate APIs.</p>
-
-<p>The @CommitAfter annotation can be useful there as well.</p>
-
-<p>You may use @CommitAfter on method of your service interface, then use a decorator
to provide the transaction management logic.</p>
-
-<p>First definine your DAO's service interface:</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 PersonDAO
+</div></div><p>In this example, the Person object may be updated by a form;
the form's success event handler method, onSuccess() has the @CommitAfter annotation.</p><p>Behind
the scenes, the @CommitAfter annotation causes the <a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/hibernate/HibernateSessionManager.html">HibernateSessionManager</a>'s
commit() method to be executed before the method returns.</p><p>The transaction
will be committed when the method completes normally.</p><p>The transaction will
be <em>aborted</em> if the method throws a RuntimeException.</p><p>The
transaction will be <strong>committed</strong> if the method throws a <em>checked</em>
exception (one listed in the throws clause of the method).</p><h1 id="HibernateUserGuide-ManagingTransactionsusingDAOs">Managing
Transactions using DAOs</h1><p>As your application grows, you will likely create
a Data Access Object layer between your pages and the Hibernate APIs.</p><p>
 The @CommitAfter annotation can be useful there as well.</p><p>You may use @CommitAfter
on method of your service interface, then use a decorator to provide the transaction management
logic.</p><p>First definine your DAO's service interface:</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 PersonDAO
 {
   Person findByName(String name);
 
@@ -257,35 +178,21 @@ public interface PersonDAO
   @CommitAfter
   void delete(Person person);
 }</pre>
-</div></div>
-
-<p>Next, define your service in your application's Module class:</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 AppModule
+</div></div><p>Next, define your service in your application's Module class:</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 AppModule
 {
    public static void bind(ServiceBinder binder)
    {
       binder.bind(PersonDAO.class, PersonDAOImpl.class);
    }
 }</pre>
-</div></div>
-
-<p>Finally, you should use the HibernateTransactionAdvisor to add transaction advice:</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;">
-    @Match("*DAO")
+</div></div><p>Finally, you should use the HibernateTransactionAdvisor
to add transaction advice:</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;">  
 @Match("*DAO")
     public static void adviseTransactions(HibernateTransactionAdvisor advisor, MethodAdviceReceiver
receiver)
     {
         advisor.addTransactionCommitAdvice(receiver);
     }</pre>
-</div></div>
-
-<p>This advice method is configured to match against any service whose id ends with
"DAO", such as "PersonDAO".</p>
-
-<p>The advisor scans the service interface and identifies any methods with the @CommitAfter
annotation.</p></div>
+</div></div><p>This advice method is configured to match against any service
whose id ends with "DAO", such as "PersonDAO".</p><p>The advisor scans the service
interface and identifies any methods with the @CommitAfter annotation.</p></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 15:20:01 2016
@@ -67,19 +67,19 @@
 
 <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)
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;}
+<div style="border-right: 20px solid #D8E4F1;border-left: 20px solid #D8E4F1;"><p>&#160;</p></div><p>Tapestry
provides a built-in integration with the Java Persistence API (JPA) through the <strong>Tapestry-jpa</strong>
module. This module supersedes the 3rd-party <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.rbtoc1479914391647 {padding: 0px;}
+div.rbtoc1479914391647 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1479914391647 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></p><div class="toc-macro rbtoc1479910788609">
+/*]]>*/</style></p><div class="toc-macro rbtoc1479914391647">
 <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>
+</li><li><a  href="#IntegratingwithJPA-ValueEncoders">Value Encoders</a></li><li><a
 href="#IntegratingwithJPA-TransactionManagement">Transaction Management</a></li></ul>
 </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;
@@ -167,7 +167,7 @@ div.rbtoc1479910788609 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><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">
+</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>Several
aspects of Tapestry-jpa can be customized 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">Whether entity value encoders will be provided automatically. See
<a  href="using-select-with-a-list.html">Using Select with a List</a>.</td></tr><tr><td
colspan="1" rowspan="1" class="conflu
 enceTd">JpaSymbols.EARLY_START_UP</td><td colspan="1" rowspan="1" class="confluenceTd">true</td><td
colspan="1" rowspan="1" class="confluenceTd"><span style="color: rgb(33,33,33);">Whether
JPA will be started up at application launch, rather than lazily.</span></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"><p>Whether the "entity" persistence strategy is used to store
JPA entities as&#160;<code>Session State Objects</code>.</p></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"><span style="color: rgb(33,33,33);">The
location of the persistence configuration file, located on the classpath </span></td></tr></tbody></table></di
 v><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 @<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="bor
 der-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
@@ -181,7 +181,7 @@ div.rbtoc1479910788609 li {margin-left:
       entityManager.persist(address);
    }
 }</pre>
-</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">
+</div></div><p>Alternatively, you can use the @Inject 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="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
@@ -236,7 +236,7 @@ div.rbtoc1479910788609 li {margin-left:
 
    ...
 }</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="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>UserDao.java</b></div><div
class="codeContent panelContent pdl">
+</div></div><h1 id="IntegratingwithJPA-ValueEncoders">Value Encoders</h1><p>The
Tapestry-jpa module automatically provides <em>value encoders</em> to make it
easy to work with entities (especially lists of entities) in your Tapestry pages and components.
This is modeled on the similar functionality from the Tapestry-hibernate-core module. See
the <a  href="hibernate-user-guide.html">Hibernate User Guide</a> for all the
details.</p><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



Mime
View raw message