0

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 ?

ThunderPhoenix
  • 1,649
  • 4
  • 20
  • 47
  • Are you looking for an affirmation? – Sahil Dave Aug 22 '13 at 09:59
  • yes! and the problem is : how to link my entity beans to the right persistence unit ? – ThunderPhoenix Aug 22 '13 at 10:10
  • Please do not confuse JPA with JSF. They have completely nothing to do with each other. JSF is in the context of this question merely one of many possible "clients" of JPA. I fixed the wrong `[jsf-2]` tag on the question. – BalusC Aug 22 '13 at 13:25

1 Answers1

3

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.

Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135