two persistence units for two schemas?

1.3k Views Asked by At

I'm using Oracle DB as RDBMS, and I want to access, via my JSF2 application, to two database schema.

So, I think I must use two <persistence-unit> in my persistence.xml ?

1

There are 1 best solutions below

0
On BEST ANSWER

If accessing two database schemas means just that some of the entities should be in different schema, that can be easily done with Table annotation:

@Entity
@Table(schema="someotherschemathandefault")
public class EntityInOtherSchema {
...
}

If those schemas need different credentials to access (or different datasources to be used), then defining two persistence units is way to go.