[jboss-user] [EJB 3.0] - Multiple Persistence Units with the same entities

Andrig Miller do-not-reply at jboss.com
Thu Apr 8 18:06:53 EDT 2010


Andrig Miller [http://community.jboss.org/people/andy.miller%40jboss.com] created the discussion

"Multiple Persistence Units with the same entities"

To view the discussion, visit: http://community.jboss.org/message/536414#536414

--------------------------------------------------------------
In developing some code, it dawned on me that I had some batch processing, and some OLTP process, and that I really wanted to configure them differently, from a JPA perspective.

So, I created two persistence units in my persistence.xml, with two different sets of Hibernate properties, pointing at the same database, and let it default to scanning for the Entities in my jar.

I also then updated my stateless session beans to have two entity managers injected one, referencing one persistent unit name, and the other referencing the other.

In the batch processing methods I use the entity manager that is configured for batch processing, and in the other methods I use the one configured for OLTP processing.

This is all working, but when I was reading various sources for whether this "should" work, it wasn't clear.

So, while it does work, what I am wondering, is this spec compliant, or is this just dumb, blind luck that it works?

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/536414#536414]

Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100408/2c869eb8/attachment.html 


More information about the jboss-user mailing list