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 ?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top