You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2007/10/02 17:51:33 UTC
svn commit: r581286 -
/myfaces/orchestra/trunk/core/src/site/xdoc/persistence.xml
Author: skitching
Date: Tue Oct 2 08:51:32 2007
New Revision: 581286
URL: http://svn.apache.org/viewvc?rev=581286&view=rev
Log:
Add some info about persistence.
Modified:
myfaces/orchestra/trunk/core/src/site/xdoc/persistence.xml
Modified: myfaces/orchestra/trunk/core/src/site/xdoc/persistence.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/site/xdoc/persistence.xml?rev=581286&r1=581285&r2=581286&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/site/xdoc/persistence.xml (original)
+++ myfaces/orchestra/trunk/core/src/site/xdoc/persistence.xml Tue Oct 2 08:51:32 2007
@@ -204,10 +204,34 @@
</section>
<section name="How to Use Orchestra Conversation Scoped Persistence">
- <p>TODO: write this section</p>
+ <p>When configured appropriately, Spring will automatically scan the beans
+ it loads for the standard persistence annotations, and injects a persistence
+ context where requested by the bean. Orchestra ensures that the persistence
+ context Spring injects is the appropriate one for the current conversation.</p>
+ <p>Your code is therefore simply straightforward:<pre>
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+public class ComponentDAO
+{
+ @PersistenceContext
+ private EntityManager entityManager;
+ ....
+}
+ </pre></p>
+ <p>Spring's annotation support does require, however, that the class containing
+ the annotation be declared as a Spring bean, and instantiated via Spring. This
+ means that all code which uses an instance of the above class needs to have it
+ injected, rather than using the new() operator to create the instance. Existing
+ code therefore may need to be restructured to take advantage of persistence
+ annotations with Orchestra. The persistence context object that Spring injects
+ is actually a proxy which looks up the correct EntityManager object to use
+ on each method call, so it is safe to use singleton scope (Spring's default
+ scope). Of course if the class has any other non-static members then the
+ scope should be set to "prototype", to avoid conflicts between different
+ instances of this class in different conversations.</p>
</section>
- <section name="Documenation Still TODO">
+ <section name="Documentation Still TODO">
<p>TODO: document Orchestra's transaction support features</p>
<p>TODO: is the persistence-context serializable? Are all persistent objects
in the context always serializable?</p>