I am using the latest version of the Hibernate tools (3.1b4) and am trying to have my generated POJO to have the following set method for one-to-one relations:
Code:
public void setFoo(Foo foo) {
this.foo = foo;
if (foo.getBar() != this)
foo.setBar(this);
}
With a many-to-one and a one-to-many relationship I am already able to generate code that looks like:
Code:
public void addToFoos(Foo aFoo) {
getFoos().add(aFoo);
aFoo.setBar(this);
}
I can generate the above code by doing various comparisons ant iterations using the mapped persistent class. Unfortunately there does not appear to be a similar mechanism for one-to-one relationships.