-
1. Re: multiple data sources
kmagnant Oct 11, 2007 6:33 PM (in response to gstacey)I just posted a very similar question in the EJB forum. If you don't get any response here, look over there. Hopefully someone will be able to point us in the right direction.
-
2. Re: multiple data sources
pmuir Oct 12, 2007 3:27 PM (in response to gstacey)"gstacey" wrote:
I'm looking into overriding EntityManagerFactory to possibly create the correct Entitymanager on login (when the source is chosen) and put it into the session at that point. Does this seem like a viable approach?
I would put the correct EntityManagerFactory into the session scope and then keep you peristence context in the conversation scope as normal. -
3. Re: multiple data sources
gstacey Nov 7, 2007 12:29 PM (in response to gstacey)I'm just now revisiting this topic (got pulled onto a higher priority project), and another concept / question occurred to me.
Since the entities are the same for all the datasources do I really need multiple persistence units? i.e. the only difference is the underlying connection right? Could I just get the delegate and change the Connection object at runtime?
It seems, on the surface, like this should work... if the connection is bound to the EntityManager and it doesn't change connections and the EntityManager is bound to the Seam session then changing the connection once, when the proper source is determined should work.
Can anyone comment on the feasibility of this? -
4. Re: multiple data sources
pmuir Nov 12, 2007 7:52 AM (in response to gstacey)Normally you bind the connection to the PU programmatically in persistence.xml - but if your underlying JPA impl allows you to safely change the connection object then there is no problem in Seam (this isn't something offered by JPA afaik, I would ask in the Hibernate forum, assuming you use Hibernate).