Hi everybody,
I'm trying to figure out how collections work, since what I see=20
makes me a little confused. Let's say that I have the following
mapping (the example in the documentation, one to many=20
monodirectional association, slightly modified):
<hibernate-mapping>
<class name=3D"eg.Parent">
<id name=3D"id">
<generator class=3D"sequence"/>
</id>
<set role=3D"children" cascade=3D"all">
<key type=3D"long" column=3D"parent_id"/>
<one-to-many class=3D"eg.Child"/>
</set>
</class>
<class name=3D"eg.Child">
<id name=3D"id">
<generator class=3D"sequence"/>
</id>
<property name=3D"name"/>
</class>
</hibernate-mapping>
Now, let's say that I open a session, read a parent and the
associated childrens, close the session, remote the objects
thru RMI (I use SessionBeans, in fact). On the client side I=20
delete a child from the collection, then pass the parent to
the server side for update: I open a session, issue and "update".
Apparently everything works fine, but from the postgres log I see that:
=2D the deleted object has not been deleted, but its parent_id column
has been nullified (if I recall properly you said this, because only
the update has been cascaded, not a delete, so I may expect this);
=2D the other columns are updated and their id is modified... why this
extra work? The other columns are unchanged...
Should I like to avoid this extra work by directly manipulating the childs,
what should I do? Should I go for a bidirectional association as in the
example provided by the documentation?
Ah, BTW, what's the meaning of cascade=3D"all" read-only=3D"true" ? If the=
=20
collection is read-only what kind of cascading is operated?
Andrea
|