> -----Original Message-----
> From: Miłosz Tylenda [mailto:mtyle...@o2.pl]
> Sent: Thursday, December 31, 2009 1:35 AM
> To: users@openjpa.apache.org
> Subject: Re: Can I map between multiple datasources?
> 
> 
> > I've been assembling an app using OpenJPA 1.2.1 for a few weeks now.
> > I've just come to the conclusion that the app is going to require
> > reading data from more than one database datasource.  One user schema
> > has most of the tables, but another user has some other tables.
> There
> > are some references between those groups of tables.
> >
> > There's no way to specify multiple datasources in a single
> persistence
> > unit, but I suppose I could implement multiple persistence units.  Is
> it
> > possible to have an entity from one persistence unit reference an
> entity
> > from another persistence unit?
> 
> I don't think there is a possibility to have an entity from one
> persistence unit reference an entity from another persistence unit.
> 
> It is my understanding that your tables reside in multiple schemas and
> you are able to perform joins between tables from different schemas at
> the SQL level. If this is the case, you can take advantage of orm.xml
> and annotations - they allow you to specify a schema for each table,
> for example:
> 
> @Table(name="CUST", schema="RECORDS")

This looks much more promising than trying to get multiple persistence units 
working together.  It all depends on whether I can be allowed to do this in our 
production database.  Here's hoping.

Thanks.

> Another idea is to check whether your database allows creation of
> synonyms/aliases. For example, with Oracle you should be able to
> execute DDL like:
> 
> create synonym CUST for OAK.CUST;

This is really just a syntactic sugar version of the previous.  It won't matter 
to JPA whether I use a synonym or reference the schema.table directly.

Reply via email to