I hope someone helps me find the answer.
I am working with an outdated database, and I cannot modify any of the existing tables, because other applications depend on them.
I have three main existing table: A, Bed and, the C .
A has a column with a link to B (many to one). The problem is that it should be related to C, not B. Therefore, I created a map of * -1 BC.
Tables: A,B,C,BC (all have ID field)
A-B many to one
B-C many to one through BC
Needed:A-C without altering A,B or C
I do not want to have Java objects for B or BC, just A and C, and A should have an Ac field
So far, I have tried to use the @Formula annotation to no avail.
class A{
@ManyToOne
@Formula(value="select BC.c from BC where BC.b = b")
private C c;
}
this creates the following SQL:
select this_.c_ID from A this_
It obviously fails because table A does not have a column c_ID (why is the formula completely ignored?).
Removing the @ManyToOne annotation yields:
select (select BC.c from BC where BC.b = this_.b) as formula_0 from A this_
, Hibernate BINARY ( C?) Integer, .
, ? @ManyToOne .
A-C A, B, C Java B BC?
,
Dan