Revision: 1248
Author: dhanji
Date: Thu Sep 16 15:32:11 2010
Log: Created wiki page through web user interface.
http://code.google.com/p/google-guice/source/detail?r=1248
Added:
/wiki/GuicePersistMultiModules.wiki
=======================================
--- /dev/null
+++ /wiki/GuicePersistMultiModules.wiki Thu Sep 16 15:32:11 2010
@@ -0,0 +1,29 @@
+#summary Multiple persistence providers with Guice Persist
+
+= Multiple Modules =
+
+So far we've seen how to use Guice Persist and JPA with a single
persistence unit. This typically maps to one data store. Guice Persist
supports using multiple persistence modules using the `private modules` API.
+
+This means that you must be careful to install all JPA modules only in
individual private modules:
+
+{{{
+Module one = new PrivateModule() {
+ protected void configure() {
+ install(new JpaModule("persistenceUnitOne"));
+ // other services...
+ }
+};
+
+Module two = new PrivateModule() {
+ protected void configure() {
+ install(new JpaModule("persistenceUnitTwo"));
+ // other services...
+ }
+};
+
+Guice.createInjector(one, two);
+}}}
+
+The injector now contains two parallel sets of bindings which are isolated
from each other. When you bind services in module `one` those services will
get the `EntityManager` from `persistenceUnitOne` and transactions around
its database.
+
+Similarly services in module `two` will have their own transactions,
`EntityManager`s etc., and these should typically not cross.
--
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.