Any other help on this topic?
In case my initial explanation wasn't clear here is a more concrete example.
I have two entities:
[code] public class Person { @ManyToOne(optional = false); Organization org;
// various other properties, getters, and setters } [/code]
and
[code] public class Organization {
@OneToMany(cascade=CascadeType.ALL, orphanRemoval=true); @Sort(type = SortType.COMPARATOR, comparator = ModelComparator.class); SortedSet<Person> members;
// various other properties, getters, and setters } [/code]
My web service looks up an instance of Organization and serializes it out to the client WITHOUT initializing the members collection (if the client wants all or part of the member list it must make a separate call). Client does its modifications and sends an update message to the server, the message body is deserialized in to a new'ed Organization object. The members collection is null just as it was when it was serialized out. I then called EntityManager#merge with the Organization and get the aforementioned error: "A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity...".
In general the system seems to be behaving as if either merge does not ever work with detached objects (which is not what I expected from reading the spec) or as if the entire object graph must be initialized before the object is detached (also not what I expected).
|