It's not too hard to find good examples on how to do this with OneToOne, but the same tactic doesn't work for me in Hibernate on a OneToMany.
I have 2 objects, both of which are subclassed from a base object type which has a composite primary key. The key is in the form (
string, integer).
the common base class for these entities is using an embeddedId class. The actual columns of interest are:
PK_STRING string;
PK_INT numeric;
And in the child entity:
FK_INT numeric;
A reasonably intuitive mapping would be:
However, that will fail because you can't mix insert/update true and insert/update false on the same joincolumn set in this configuration.
Adding a "@MapsId" annotation to the front of that will get rid of the insert/update conflict, but then I get the error that FK_INT cannot be null, despite having been explicitly advised otherwise.
PK_STRING must never be null, since it's part of the object's primary key.
FK_INT must be nullable, because the parent object of this relationship is optional, and therefore the returned property for the parent object can be null.
Since I can't get in touch with the people on the inside of Hibernate, does anybody here have any ideas?