Skip to main content



      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 16:44 Go to next message
Eclipse UserFriend
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() {    
    emA.getTransaction().begin();
    AlunoED ed = emB.find(AlunoED.class, 16);  // find uses a different EM 
    ed.setNomeAlu(ed.getNomeAlu() + "Alterado");
    emA.merge(ed);  
    emA.flush();
    emA.getTransaction().commit();
  }


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 15:08 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Example of EclipseLink-EMF integration
Next Topic:Problem with column data type when using Converters
Goto Forum:
  


Current Time: Thu Jul 24 13:25:02 EDT 2025

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

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

Back to the top