Hibernate version: 2.1.6
DBMS: PostgreSQL (or any DBMS with schemas (i.e., namespaces))
Has anyone run into this situation before and solved the problem?
Basically, I want to have N schemas that each contain the same tables (and dynamically choose one schema at runtime to use via "unqualified names", e.g., select * from foobar ... will resolve to A.foobar, B.foobar, ...). So far, so good.
Now, let's say that I have 3 schemas, X, A and B.
A contains table foobar
B contains table foobar
X contains table baz, that contains a FK to foobar.
The FK early-binds at definition time to one and only one particular schema, which obviously must be the case, but which yields "every schema is an island" (choosing schema dynamically, as above, will lead to db integrity violation)... not terribly useful. (I want to partition companies' data in A and B, but said data needs to relate to common data in schema X.)
I think that Hibernate joined-subclass could be used to effect a "root" (in the OODBMS sense) in schemas A and B. This leaves me feeling underwhelmed though.
Any thoughts on this problem?
-------------------------------------
Hibernate joined-subclass comment: why do my subclasses have to have different classnames, even when they reside in different packages; the fact that Hibernate won't let me name them identically is an extra inconvenience.
|