Here's an interesting situation I discovered with the OneToOne associations and the bidirectional association management. Suppose there are two entities: StockAllocation and OrderLine.
Inside OrderLine entity I have:
And inside StockAllocation entity I have:
Now after these 2 classes have been enhanced, suppose at some point I want to unset the orderLine from the stockAllocation, I do it in the following way:
This sets the stockAllocation to null on the orderLine entity, but is doesn’t set the orderLine to null on the stockAllocation entity. Wasn’t the bytecode enhancement supposed to do that?, by changing one side of a bi-directional relation, the other side gets updated as well?
If I look the the bytecode, I see the following:
The stockAllocation is indeed set to null (the argument of this method is null), but the orderLine from the stockAllocation isn’t set to null, because the first IF will be true only when the argument of the method will be not null.
Is this an expected behavior or a bug?
A test case has been attached.