| [news.eclipse.rt.eclipselink] Re: use one connectio nper user - no connection pool |
Yeah. Maybe the EclipseLink developers can shed a light on this. I would expect the code I pasted to return two different EMF's when different u/p are provided.
Tom
Thank you so much, unfortunately this doesn't work either. I think it worked for you because you have not a shared environment. The class persistence just doesn't create the emf twice. I think the emf is stored as singleton. I somehow need get it working by setting username and password on the entitymanager. I managed to to do that, but I still end up in an NPE while proccessing ConnectionPolicyProperties, don'nt know what that means at all.
tbee schrieb:That most definitely works, because that is the way I do it. Has been running in production for a year now:
static public EntityManagerFactory createEntityManagerFactory(Class
jdbcDriver, String jdbcUrl, String jdbcUsr, String jdbcPwd)
{
Map<String, Object> lOptions = new HashMap<String, Object>();
lOptions.put(PersistenceUnitProperties.JDBC_DRIVER, jdbcDriver);
lOptions.put(PersistenceUnitProperties.JDBC_URL, jdbcUrl);
lOptions.put(PersistenceUnitProperties.JDBC_USER, jdbcUsr);
lOptions.put(PersistenceUnitProperties.JDBC_PASSWORD, jdbcPwd);
lOptions.put(PersistenceUnitProperties.TARGET_DATABASE,
InformixPlatform.class.getName());
lOptions.put(PersistenceUnitProperties.TARGET_SERVER,
TargetServer.None);
lOptions.put(PersistenceUnitProperties.JOIN_EXISTING_TRANSACTION,
"true"); // reads and write should go through the same connection
lOptions.put(PersistenceUnitProperties.CACHE_SHARED_DEFAULT,
"false"); // do not use the shared cache (otherwise refresh will not
update from db)
lOptions.put(PersistenceUnitProperties.LOGGING_EXCEPTIONS,
"true");
EntityManagerFactory lEntityManagerFactory =
Persistence.createEntityManagerFactory("reinders", lOptions);
// done
return lEntityManagerFactory;
}
Tom
Thomas Haskes wrote:Oh, I see. You mean setting the user and password properties at the EntityManager like this:
HashMap map = new HashMap(); map.put(EntityManagerProperties.JDBC_USER, "John"); map.put(EntityManagerProperties.JDBC_USER, "pass"); emf.createEntityManager(map);
If you meant that. this didn't work. Unfortunately this Results in a login using "" as username, which I consider a bug.
If did not mean that, sorry, then I couldn't follow you. Could you provide me with a little snippet then? Sorry if I'm puzzled. Please set me straight.
tbee schrieb:No. I mean "Em1" and "Em2", each having its own user set using the properties parameter in Java.
Are you configuring the users in the persistence.xml?
Tom