Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] How to work with multiple databases/schemas

James Sutherland wrote on 2009-05-11 22:24:
In JPA the EntityManagerFactory is always cached.  So if you access the same
factory name twice, you will get the first instance back.  So you cannot
change your login parameters and get a different factory back.  The only way
to do this is to either create a separate persistence unit, or first close
all references to the first EntityManagerFactory, then create a new one
using the new login.

Thanks this helps me, too.
You have to know that is some kind of singleton... the API documentation could be more precise with that. Instead Persistence.createEntityManagerFactory it should have been named Persistence.getEntityManagerFactoryInstance ;-)




Back to the top