Revision: 1243
Author: dhanji
Date: Thu Sep 16 14:24:58 2010
Log: Edited wiki page JPA through web user interface.
http://code.google.com/p/google-guice/source/detail?r=1243

Modified:
 /wiki/JPA.wiki

=======================================
--- /wiki/JPA.wiki      Thu Sep 16 14:20:40 2010
+++ /wiki/JPA.wiki      Thu Sep 16 14:24:58 2010
@@ -38,10 +38,11 @@

To tell Guice Persist which persistence unit you wish you use, you specify its name when creating your module:

-
-`Injector injector = Guice.createInjector(..., new JpaModule("*myFirstJpaUnit*"));`
-
-Finally, you must decide when the persistence service is to be started by invoking `start()` on `PersistService`. I typically use a simple initializer class that I can bind and invoke at a time of my choosing:
+{{{
+Injector injector = Guice.createInjector(..., new JpaModule("myFirstJpaUnit"));
+}}}
+
+Finally, you must decide when the persistence service is to be started by invoking `start()` on `PersistService`. I typically use a simple initializer class that I can trigger at a time of my choosing:

 {{{
 public class MyInitializer {
@@ -53,7 +54,9 @@
 }
 }}}

-It makes good sense to use Guice's Service API to start all services in your application at once, but I recommend you think about how it fits into your particular deployment environment before doing so. In the case of web applications, you do not need to do anything if you simply install the `PersistFilter`. +It makes good sense to use Guice's [Service API] to start all services in your application at once. I recommend you think about how it fits into your particular deployment environment when doing so.
+
+However, in the case of web applications, you do not need to do anything if you simply install the `PersistFilter` (see below).

 == Session-per-transaction strategy ==

@@ -63,8 +66,8 @@
  <persistence-unit name="myFirstJpaUnit" transaction-type="RESOURCE_LOCAL">
 }}}

-Using the EntityManager inside Transactions
-Once you have the injector created, you can freely inject and use an EntityManager in your transactional services:
+== Using the EntityManager inside transactions ==
+Once you have the injector created, you can freely inject and use an `EntityManager` in your transactional services:

 {{{
 import com.google.inject.persist.Transactional;
@@ -80,16 +83,18 @@
 }
 }}}

-Note that if you make `MyService` a `...@singleton`, then you should inject `Provider<EntityManager>` instead. This is known as the _session-per-transaction_ strategy.
+This is known as the _session-per-transaction_ strategy.
+
+Note that if you make `MyService` a `...@singleton`, then you should inject `Provider<EntityManager>` instead.

 == Web Environments (session-per-http-request) ==

-So far, we've seen the session-per-transaction strategy. In web environments this is atypical, and generally a _session-per-http-request_ is preferred (sometimes also called _open-session-in-view_). To enable this strategy, you first need to add a filter to your ServletModule: +So far, we've seen the session-per-transaction strategy. In web environments this is atypical, and generally a _session-per-http-request_ is preferred (sometimes also called _open-session-in-view_). To enable this strategy, you first need to add a filter to your `ServletModule`:

 {{{
 public class MyModule extends ServletModule {
   protected void configureServlets() {
- install(new JpaModule("myJpaUnit")); // similar to what we saw earlier.
+    install(new JpaModule("myJpaUnit"));  // like we saw earlier.

     filter("/*").through(PersistFilter.class);
   }

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to