In the past 2 weeks I’ve browsed your forums and googled through the web in attempt to find a lead for the problem we’re facing. I found several posts on this topic that suggested similar mappings to what is currently defined at our project. However, in most of the cases the business logic was different, which I guess explains, why only us are “stuck” with unreferenced records in the database.
So let me provide some additional info about the project environment and hopefully you could point on the root cause.
We’re using Hibernate 2.0, dialect: SybaseAnywhereDialect.
The database structure: Container 1--* Map of Commands *--* Command
Due to the business logic of the application, all the CRUD operations are made to the Container objects. So if a Command was deleted from the UI, the Command object is removed from the map and the Container object is updated (using session.update , which is also the only code between session.openSession() and session.close()). The map related DB table reflects the change, however in the command table, the deleted records still appear.
Here are the mappings:
Container:
Code:
<class name="x.y.z. Container" table="CONTAINER">
<id name="id" column="ID">
<generator class="assigned" />
</id>
<property name="attr1" column="attr1" type="integer"/>
<property name="attr2" column=" attr2" type="integer"/>
<map name="CommandMap" table="COOMAND_MAP" cascade="all">
<key column="REF_ID"/>
<index column="ORDER" type=”int”/>
<many-to-many column="COMMAND_ID" class="x.y.z.Command"/>
</map>
</class>
[b]Command:
Code:
<class name="x,y,z.Command" table="COMMAND">
<id name="id" column="ID">
<generator class="assigned"/>
</id>
<version column="version" name="version" type="integer" access="property" unsaved-value="undefined"/>
<property name="prop1" column=" prop1" type="boolean"/>
<property name=" prop2" column=" prop2" type="boolean"/>
</class>
Any help would be greatly appreciated.