Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Two entity manager appointing to the same daba base
Two entity manager appointing to the same daba base [message #553258] Mon, 16 August 2010 20:44 Go to next message
Mauro Flores is currently offline Mauro FloresFriend
Messages: 84
Registered: September 2009
Location: Brasil
I'm working with a legacy database. This database is not relational and it has a proprietary query language.

There two different kinds of jdbc drivers that enable the access to it throw sql commands. One driver doesn't support insert, updates and deletes. The other supports all sql commands, but doesn't have a good query performance.

I would like to use one jdbc for queries and the other for updates, inserts and deletes.

I will work with one entity manager for each jdbc driver. The entities will be exactly the same.

My doubt is: can I update a entity with one entity manager that was loaded by the other?

The simple test below worked nice:

  public void test() {    
    AlunoED ed = emB.find(AlunoED.class, 16);  // find uses a different EM 
    ed.setNomeAlu(ed.getNomeAlu() + "Alterado");

Would I face some problem using this aprouch?

Thanks. Mauro.
Re: Two entity manager appointing to the same daba base [message #554633 is a reply to message #553258] Mon, 23 August 2010 19:08 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Merge will work, but you need to be careful of how your related objects are updated/merged as well.

Another option is that EclipseLink supports both a readConnectionPool and a writeConnectionPool, and you can use a different login for both.

You can use a SessionCustomizer to configure the read ConnectionPool on your ServerSession.

James : Wiki : Book : Blog : Twitter
Previous Topic:Example of EclipseLink-EMF integration
Next Topic:Problem with column data type when using Converters
Goto Forum:

Current Time: Thu Apr 19 18:02:27 GMT 2018

Powered by FUDForum. Page generated in 0.01730 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software