0

I am starting to develop OpenXava apps to replace an old system (Delphi programs using a Firebird database), but the new apps will have Postgres as the data store.

The app I am developing now needs to have read-only access to 2 tables from the old Firebird database (thus not modifying them whatsoever!) and everything else will be in the new Postgres database (basically, 2 entities from one database and about 4 from another).

Eventually everything will be moved to Postgres, but while the integration is happening, I need to be doing things like these.

Is there a way to do this in OpenXava? Any suggestions on how to tackle this problem will be greatly appreciated.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Erick Tejada
  • 261
  • 3
  • 6
  • 14
  • Consider doing it via PostgreSQL, using a foreign data wrapper like `odbc_fdw`. So to the application it looks like they're just PostgreSQL tables, and behind the scenes PostgreSQL fetches the data from Firebird. – Craig Ringer Sep 05 '15 at 06:34

1 Answers1

1

You can define a second persistence-unit in your persistence.xml against your old database, then when you need to access to the old database use the JPA syntaxt instead of XPersistence.getManager() to get a manager against your old database, thus:

EntityManagerFactory f = 
    Persistence.createEntityManagerFactory("firebird");
EntityManager manager = f.createEntityManager();  
manager.getTransaction().begin();  

// Your code

manager.getTransaction().commit();  
manager.close();  // You have to close
javierpaniza
  • 677
  • 4
  • 10