Pretty odd thing in fact, I changed the fetching of the relationship to
EAGER and that solved the problem .... I can't understand why; it might
be a bug or maybe I'm just doing something wrong.
That's not the best for us as we usually have lot's of states for one
Issue object and we (almost) always care just about the last one, but we
could live with that: we've been taken some measures and don't loose too
much performance.
By the way, what you mean with mantain the relationship correctly?
When adding a new StateAssignment I just create the objet, add it to the
list and merge the Issue object. The cascade on updating triggers the
insert of the new StateAssignment objet in the db.
At first I created the StateAssignment object, persisted it alone, then
I added to the list and merged the Issue object, but I found that was
redundant (I think).
On deleting I take the StateAssignment object off from the list, call
the remove method of EntityManager on that object and then merge the Issue.
That's been working correctly for me until now, is that the way this
kind of relationship is meant to be mantained?