This is because OJB uses the RemovalAwareCollection for collections by default. This collection deletes all objects that are removed. You want to switch to one of the Manageable collections <http://db.apache.org/ojb/api/org/apache/ojb/broker/util/collections/package-summary.html>. You will need to add the "collection-class" attribute to your collection descriptor to specify which class to use. It will look something like:
<collection-descriptor
name="monitors"
element-class-ref="com.contego.arx.domain.Monitor" collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
indirection-table="ccp_monitor_package_monitor">
<fk-pointing-to-this-class column="monitor_package_id"/>
<fk-pointing-to-element-class column="monitor_id"/>
</collection-descriptor>
Mike
Chris Widhelm wrote:
Does anyone have any ideas on this?
It just seems odd that by removing an item from a collection that it performs a delete on the object that is in the collection.
Thanks,
Chris
----- Original Message ----- From: "Chris Widhelm" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Thursday, September 04, 2003 4:21 PM
Subject: non-decomposed m:n mapping deleting incorrectly
I have a non-decomposed m:n mapping set up with an inderection table and for some reason when I call Collection.remove( Object ) it is deleting not only the mapping in the inderection table, but also the object that is mapped by the inderection table.
How do I stop this behavior?
See my configuration below:
=================================== <class-descriptor class="com.contego.arx.domain.Monitor" table="ccp_monitor"> <field-descriptor name="id" column="id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> <field-descriptor name="monitorName" column="monitor_name" jdbc-type="VARCHAR"/> <field-descriptor name="displayName" column="display_name" jdbc-type="VARCHAR"/> <field-descriptor name="description" column="description" jdbc-type="VARCHAR"/> <field-descriptor name="configurationString" column="configuration_string" jdbc-type="VARCHAR"/> <field-descriptor name="url" column="url" jdbc-type="VARCHAR"/> </class-descriptor>
<class-descriptor class="com.contego.arx.domain.MonitorPackage" table="ccp_monitor_package"> <field-descriptor name="id" column="id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> <field-descriptor name="packageName" column="package_name" jdbc-type="VARCHAR"/> <field-descriptor name="description" column="description" jdbc-type="VARCHAR"/> <collection-descriptor name="monitors" element-class-ref="com.contego.arx.domain.Monitor" auto-retrieve="true" auto-update="false" auto-delete="false" indirection-table="ccp_monitor_package_monitor"> <fk-pointing-to-this-class column="monitor_package_id"/> <fk-pointing-to-element-class column="monitor_id"/> </collection-descriptor> </class-descriptor>
===================================
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
