Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] multiple EntityManagers in one process

OK, after asking that question, I found the following thread:
http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg02625.html

So this is my understanding:

A singleton ServerSession is associated with a named persistence unit. Any EntityManagerFactory/EntityManager created under that PU name will share the same ServerSession.

Is this correct?

I need to create a schema associated with my existing PU in the new database. Is it possible to create a new PersistenceUnit name on the fly?

On May 20, 2009, at 4:08 PM, David Parker wrote:

I am trying to build a schema migration functionality that requires separate connections to different databases.

What is happening is that the first entitymanagerfactory is initialized, connected to its database. Then I create another entitymanagerfactory with a different set of connection properties, using

   public static String JPA_DRIVER_PROP = "eclipselink.jdbc.driver";
   public static String JPA_URL_PROP = "eclipselink.jdbc.url";
   public static String JPA_USER_PROP = "eclipselink.jdbc.user";
public static String JPA_PASSWORD_PROP = "eclipselink.jdbc.password";

property names. Despite creating a "new" EntityManagerFactory object with a different set of properties, it still connects to the original database, i.e., it has the same connection information internally as the original entitymanagerfactory. I notice that it shares the same DatabaseAccessor object.

I'm clearly not understanding how this is supposed to work. What is the correct way to go about maintaining connections to separate databases?

Thanks.

=============================================
David Parker
dap@xxxxxxxxxxxxxxxxxxxx




_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


=============================================
David Parker
dap@xxxxxxxxxxxxxxxxxxxx






Back to the top