Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Overwrite session manager settings

Hi Jaka,

I just spoke to a colleague and he mentioned that the behavior is exposed through properties.

The key is to create a working EntityManagerFactory with the strategy listed below. (i.e. Provide working connection information at the creation of the EMF)

Once you have done that, you can create EntityManagers with alternate connection information using the properties in org.eclipse.persistence.config.EntityManagerProperties. Note: They are the same strings as the ones you use for EntityManagerFactory creation. The limitation here is that you must connect to a database that uses the same EclipseLink DatabasePlatform.

Once again, the recommended approach for most applications is to use the settings in EntityManagerFactory. The additional functionality is available for applications that have more complicated connection requirements.

-Tom

Jaka Janc(ar wrote:
Tom,

is it possible to specify the database server on an EntityManager basis?

In other words, what can you do if you want to connect to loads of different hosts, but don't want to recreate EntityManagerFactory for each one (since that takes ages).

Jaka

On 19. Mar 2009, at 19:23, Tom Ware wrote:

Hi Phil,

In EclipseLink, EntityManagerFactory holds the object that controls database connections. As a result you need to provide the database properties to the EntityManagerFactory at creation time. (In the bootstrap API, a Map can be provided to the Persistence.createEntityManagerFactory(String, Map) method.)

If you need to regulate these things on an EntityManager basis, there is some EclipseLink specific API that can be used to do that, but for most people, the general API is sufficient.

-Tom

Philipp Kursawe wrote:
Is it possible to overwrite the settings made in the persistence.xml when creating the EntityManager using an EntityManagerFactory.create(Map)?
It seems like that the properties I am handing in are not valued.
Is it in any other way possible to set certain persistence.xml values from within the program? I mean I cannot seriously be asked to put login credentials inside a JAR? I would like the user to configure those values and feed them to EclipseLink programmatically not from the persistence.xml.
Thanks for your help!
Phil
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

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


Back to the top