-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Using multiple persistence units/EntityManagerFactories
PostPosted: Tue May 30, 2006 7:37 am 
Newbie

Joined: Tue May 30, 2006 7:26 am
Posts: 1
Hi,

since the JBoss EJB3 forum didn't help, I am asking my question here - in particular because Hibernate's proprietary EntityManager API might help.

Although I would assume that what I'm trying to achieve is a rather common problem, I am still struggling with how to solve it in EJB 3.

I would like to be able to define separate database "realms" for an application which can be used in parallel. The application is based on EJB3 EntityBean POJOs. Here, I define "realm" as a place to which the data model is persisted, i.e. the same model should be persistable to different databases depending on the context of an access.
For example, I'd like to be able to say
- store all stuff in data source java:/some-mysql-database for the context "realm 1" and
- store all stuff in data source java:/some-oracle-database for the context "realm 2"
all within the same running JBoss instance.

On the DAO side my approach is to
- encode the context inside the principal of (authenticated) accesses (all accesses are necessarily authenticated)
- intercept calls using standard EJB3 interceptors which provide injection of a context-dependant EntityManager on a per-call basis.

Implementing the above approach requires the configuration of a separate persistence unit per context. What I'm currently lacking is a way to programmatically configure the persistence unit/EntityManagerFactory from a default "template" while overriding the data source.

I found this http://www.jboss.com/index.html?module= ... ic&t=82781 which doesn't sound very encouraging. If the data source cannot be overridden, configuration becomes considerably harder because of the necessity to mangle the persistence.xml if a new context is to be configured.

Now I'm wondering whether what I'm trying to do is really that exotic or maybe if problems of this class are supposed to be tackled in a completely different way.

Thanks in advance
Joerg Henne


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.