Web App with multiple persistence units

337 views
Skip to first unread message

jdestef

unread,
Jul 7, 2011, 3:09:13 PM7/7/11
to google-guice
Hi,

I'd like to use a second persistence unit in a web application. I have
a persistence module that currently looks something like this:

public MyServletModule extends ServletModule {
.........
........

// Jpa
install(new JpaPersistModule("unitName"));
filter("/*").through(PersistFilter.class);
}

The documentation suggests installing multiple units using the
PrivateModule class. It also says indicates that filter("/
*").through(PersistFilter.class); can be called multiple times for
each private JpaModule. I tried the following but get binding errors
for PersistService and UnitOfWork:

public MyServletModule extends ServletModule {
.........
........

// Jpa
PrivateModule priv = new PrivateModule {
install(new JpaPersistModule("unitName"));
filter("/*").through(PersistFilter.class);
}

install(priv);

}

Has anyone successfully implemented this feature. I've seem only a
couple of posts on the forum about the subject. It would be great if
there was an example of this in the tests for the persist extension.

Any help appreciated.

Thx

dhanji

unread,
Jul 8, 2011, 8:57:20 PM7/8/11
to google-guice
Do you mean it complains about UnitOfWork not being bound?

In that case you need to expose the binding. Multiple modules are a
bit experimental at the moment, and no one has really developed around
them afaik.

the now-defunct warp-persist project has had support for multiple
modules for awhile though.

Dhanji.

jdestef

unread,
Jul 11, 2011, 10:13:56 AM7/11/11
to google-guice
Hi,

I'm having the same issue as:
http://groups.google.com/group/google-guice/browse_thread/thread/a984cd0c90e8414e/47501069e845aac2?lnk=gst&q=persistence+unit+multiple#47501069e845aac2

I did expose the unitofwork and persistenceservice and deployed the
app with only one private persistence module and thus one persistence
unit. This worked. When I added the second private module, which was
configured the same except it had my other persistence unit bound to
it, I got the same exception.

Is there any guidance you could provide as to solving this issue. The
current approach in guice for one persistence unit works quite well
and is very easy to configure.

Thx

scl

unread,
Oct 19, 2011, 6:20:05 AM10/19/11
to google...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages