[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Overwrite session manager settings
|
You must use some connections in the second EMF, I am assuming that
connection string is the same as in the first EMF.
Eclipselink uses by default shared cache for all objects it handles, so
consider defining the separate cache for the classes you will handle in EM
created with connection strings.
Defining of non-shared caches is done when EMF is created by passing the
properties to createEMF (or specifying the properties in persistence.xml):
//for each class that requires isolated cache
"eclipselink.cache.shared.myPackage.MyClass" "false"
//alternatively you can use a single property in case all classes require
isolated cache
"eclipselink.cache.shared.default" "false"
To createEM along with a new connection properties, pass:
"eclipselink.jdbc.exclusive-connection.mode" "Isolated"
----- Original Message -----
From: "Jaka Jančar" <jaka@xxxxxxxxx>
To: "EclipseLink User Discussions" <eclipselink-users@xxxxxxxxxxx>
Sent: Thursday, April 02, 2009 7:42 AM
Subject: Re: [eclipselink-users] Overwrite session manager settings
Hi Tom,
I'm having a problem with this approach: the wrong connections are
being used for the persistence units.
I have two Persistence Units defined in persistence.xml: ClusterPU and
InstancePU. The EMF for ClusterPU is created normally, supplying JDBC
data and not overriding it in createEM(). The EMF for InstancePU is
created without supplying JDBC data and setting it each time in
createEM().
After the EMFs are created, I create an EM for ClusterPU, the pool is
initialized and all works fine for ClusterPU.
The problem is with InstancePU (the one with per-EM JDBC parameters):
If I save an entity (instanceEm.persist(entity)) a new connection is
established and all works fine. However if I try to load an entity
(instanceEm.find(entityClass, entityId)), a connection from ClusterPU
will be used, instead of a new one being created, which is completely
incorrect!
Any ideas?
Jaka
On 19. Mar 2009, at 20:39, Jaka Jančar wrote:
Hmm... this is awesome, I'll check it out.
Hibernate does not support this at all, btw :)
Jaka
On 19. Mar 2009, at 19:50, Tom Ware wrote:
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
_______________________________________________
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