I am trying to reorder a list selection within the database. Say I have a choice set called "Cities" and have several cities as children of the "Cities" choice. I have a method to reorder the children alphabetically so that their list indexes are in the correct order, but, when I attempt to persist it to the database, nothing in the database changes. Also, if I attempt to move a state, for example, from the "Cities" group to the "State" group, it is not moved. For some reason, the list indexes and added children are only persisted when I add an option to the choice table after attempting to persist the reordered choices. Because I do not wish to delete items from this table, I have to go in and alter the mapping to allow me to delete the newly added Choice that I really don't want in there in the first place.
So, in short, if the "choice" table itself is not updated, the "choice_map" table will not be updated. Any ideas on why it is not persisted when the children are re-ordered or moved to another parent? Any help would be greatly appreciated.
Here is my hibernate mapping:
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-cascade="all"> <class name="com.test.Choice" table="choice" schema="test" mutable="false"> <cache usage="read-only"/> <id name="uid" column="uid" type="long"> <generator class="hilo"/> </id> <version name="version"/> <list name="choices" table="choice_map" schema="test" cascade="all" lazy="true"> <key column="choiceId"/> <index column="listIndex"/> <many-to-many class="com.test.Choice"/> </list> <component name="data" class="com.test.ChoiceData"> <property name="id" length="25" not-null="true"/> <property name="name" length="100" not-null="true"/> <property name="value" length="50" not-null="true"/> <property name="description" length="500"/> <property name="language" length="25"/> <property name="isGroup" type="boolean"/> </component> </class>
</hibernate-mapping>
|