Hi Peter,
On Aug 15, 2006, at 6:48 PM, Peter Karich wrote:
>> I may be misreading your message, but isn't this as simple as not
>> defining the reverse relationship? That's why the documentation
>> says
>> "if"
>
> Sorry, I mean: I defined "A has many B" and "B has many A" in the
> modeller.
> And now: how can I suppress automatic update, because sometimes it
> is useful for me to have
> a programmatic UNI-directional relation instead of the defined Bi-
> directional one.
What Mike says still applies - you can define an ObjRelationship as
unidirectional in the model, and this should prevent an auto-update
of the reverse side.
If this is not desirable for any reason, and you want to map a
relationship as bi-directional, but suppress the reverse update, you
can override a few DataObject methods in your subclasses (or in a
wedge class that sits between CayenneDataObject and a mapped entity
class to make it a global rule):
public void removeToManyTarget(String relName,
DataObject val,
boolean setReverse) {
// always use 'false'
super.removeToManyTarget(relName, val, false);
}
public void setToOneTarget(String relName,
DataObject val,
boolean setReverse) {
// always use 'false'
super.setToOneTarget(relName, val, false);
}
public void addToManyTarget(String relName,
DataObject val,
boolean setReverse) {
// always use 'false'
super.addToManyTarget(relName, val, false);
}
Andrus
This archive was generated by hypermail 2.0.0 : Wed Aug 16 2006 - 10:05:24 EDT