[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Overwrite session manager settings
|
Reads will normally use the login information from the EntityManagerFactory.
This is because the shared cache should use a common login. You can do this
however using the property,
"eclipselink.jdbc.exclusive-connection.mode"="Always"
See,
http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/config/PersistenceUnitProperties.html#EXCLUSIVE_CONNECTION_MODE
You can also disable the shared cache using,
"eclipselink.cache.shared.default"="false"
Or disable on a per class basis.
Jaka Jančar wrote:
>
> 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
>>>>>
>
>
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Overwrite-session-manager-settings-tp22606192p22849307.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.