Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Connecting to multiple different databases efficiently

EclipseLink supports this through its exclusive connection support (in
EclipseLink 1.1).

If you set the property:
"eclipselink.jdbc.exclusive-connection.mode"="Always"

and your login properties, it will use those properties to connect another
connection.  You will most likely also want to disable the shared cache in
your main persistence.xml, and set your connection pool min size to 0 or 1. 
You could also load some classes from a shared database and others from the
new database by setting the mode to "Isolated" and only isolated (setting
shared cache to false) for some classes.

"eclipselink.cache.shared.default"="false"

See,
http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/config/ExclusiveConnectionMode.html



Jaka Jančar wrote:
> 
> Hi!
> 
> I haven't actually used EclipseLink much yet, only Hibernate. I'm  
> writing this mail to ask if EclipseLink supports something I need, but  
> which Hibernate unfortunately doesn't support.
> 
> I'm developing a servlet which needs to connect to one of many  
> databases, depending on the request. I'm using application-managed  
> entity mangers and resource-local transactions.
> 
> To make it as fast as possible, I would like to create the  
> EntityManagerFactory with all the common settings in init() and then  
> only override connection details (database URL specifically) when  
> creating the EntityManager in service():.
> 
> Theoretically, this should IMO be possible, since JPA supports  
> overriding properties both in  
> Persistence.createEntityManagerFactory(pu, map) and in  
> EntityManagerFactory.createEntityManager(map).
> 
> It seems, however, that both Hibernate and EclipseLink ignore  
> connection properties (hibernate.connection.* and eclipselink.jdbc.*)  
> when passed to EntityManagerFactory.createEntityManager(map).
> 
> I realize and accept that this might prevent caching of database  
> connections.
> 
> Does EclipseLink support this use case in any way?
> 
> Regards,
>   Jaka
> 
> 


-----
---
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/Connecting-to-multiple-different-databases-efficiently-tp22459049p22475765.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top