Hi,
I'm trying to do a unidirectional one-to-one mapping for a legacy database where the primary key of the other side of the join is available on the owning side, but not the other way around...
Code:
class A {
// PK
String getNewGUID() ...
// Regular property known to be unique and one-to-one with B.getId()
String getOldId() ...
// How to specify this as a one-to-one?
B getB() ...
...
}
class B {
// PK
String getId() {...}
...
}
From the docs I get the impression this could be done with a formula:
"Almost all one to one associations map to the primary key of the owning entity. In the rare case that this is not the case, you may specify a some other column, columns or expression to join on using an SQL formula."
But I'm not clear on what the syntax would be. I've taken a look at the org.hibernate.test.onetoone.formula example, but that is a slightly different scenario.
Also, this mapping is for read-only data.
Any pointers would be most appreciated.
Thanks,
Ian