deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r884376 - in /websites/staging/deltaspike/trunk/content: ./ jpa.html
Date Sun, 27 Oct 2013 19:37:39 GMT
Author: buildbot
Date: Sun Oct 27 19:37:39 2013
New Revision: 884376

Log:
Staging update by buildbot for deltaspike

Modified:
    websites/staging/deltaspike/trunk/content/   (props changed)
    websites/staging/deltaspike/trunk/content/jpa.html

Propchange: websites/staging/deltaspike/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sun Oct 27 19:37:39 2013
@@ -1 +1 @@
-1535989
+1536188

Modified: websites/staging/deltaspike/trunk/content/jpa.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/jpa.html (original)
+++ websites/staging/deltaspike/trunk/content/jpa.html Sun Oct 27 19:37:39 2013
@@ -102,7 +102,7 @@ If you are using features described by t
 <p>The following example shows a simple producer for an <code>EntityManager</code>
and the corresponding dispose-method.
 Producing it as request scoped bean means that the dispose method will be called on finishing
the request.
 As an alternative it's possible to use a special scope called <code>@TransactionScoped</code>
provided by the same DeltaSpike module.</p>
-<p>Producer for the default EntityManager:</p>
+<p>Producer for the default EntityManager (no EE-Server):</p>
 <div class="codehilite"><pre><span class="c1">//...</span>
 <span class="kd">public</span> <span class="kd">class</span> <span
class="nc">EntityManagerProducer</span>
 <span class="o">{</span>
@@ -128,6 +128,32 @@ As an alternative it's possible to use a
 </pre></div>
 
 
+<p>Producer for the default EntityManager (EE-Server):</p>
+<div class="codehilite"><pre><span class="nd">@ApplicationScoped</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">EntityManagerProducer</span>
+<span class="o">{</span>
+    <span class="nd">@PersistenceUnit</span>
+    <span class="kd">private</span> <span class="n">EntityManagerFactory</span>
<span class="n">entityManagerFactory</span><span class="o">;</span>
+
+    <span class="nd">@Produces</span>
+    <span class="nd">@Default</span>
+    <span class="nd">@RequestScoped</span>
+    <span class="kd">public</span> <span class="n">EntityManager</span>
<span class="nf">create</span><span class="o">()</span>
+    <span class="o">{</span>
+        <span class="k">return</span> <span class="k">this</span><span
class="o">.</span><span class="na">entityManagerFactory</span><span
class="o">.</span><span class="na">createEntityManager</span><span
class="o">();</span>
+    <span class="o">}</span>
+
+    <span class="kd">public</span> <span class="kt">void</span> <span
class="nf">dispose</span><span class="o">(</span><span class="nd">@Disposes</span>
<span class="nd">@Default</span> <span class="n">EntityManager</span>
<span class="n">entityManager</span><span class="o">)</span>
+    <span class="o">{</span>
+        <span class="k">if</span> <span class="o">(</span><span
class="n">entityManager</span><span class="o">.</span><span class="na">isOpen</span><span
class="o">())</span>
+        <span class="o">{</span>
+            <span class="n">entityManager</span><span class="o">.</span><span
class="na">close</span><span class="o">();</span>
+        <span class="o">}</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+
 <p>The following examples show how to use the <code>EntityManager</code>
produced by the example above.</p>
 <p>Beans with transactional method:</p>
 <div class="codehilite"><pre><span class="c1">//...</span>



Mime
View raw message