Toplink essentials: Create EntityManagers with different username/password
Hi everybody!
I would like to use the TopLink JPA implementation for my Servlet Web Applikation running on TomCat, but I have a few open Questions.
As far as I know a EntityManagerFactory should be created once for a application. But I cant use the same user/password for each user, I need a named user. I have found out that I can make a property map with username and password and create a EntityManagerFactory like this:
Map<String, String> connectProps = new HashMap<String, String>();
connectProps.put(TopLinkProperties.JDBC_USER, "myusername");
connectProps.put(TopLinkProperties.JDBC_PASSWORD,"myuserpassword");
EntityManager emf = Persistence.createEntityManagerFactory("default", connectProps);
But this property map does not work with the method createEntityManager(properties) from the EntityManagerFactory, (emf.createEntityManager(connectproperties) I always get a illegal argument exception.
I found in the Open JPA documentation that it should be possible there to create EntityManagers with the .createEntityManager(Map properties) and define username / password in the property map.
Is it a limitation of the Oracle Toplink JPA implementation that only a EntityManagerFactory accepts username/password for creation?
Many thanks for your help,
Best regards,
Alex Schaefer