Hi,
I am using Hibernate Version 2.1.6 in our application, which is J2EE app with Struts and SQL server 2000 DB.
In our application, I have a problem in retrieving values from the JSP for a Set of ChildVOs, which is part of a ParentVO. This set is a SortSet (sort="natural") with childNumber as the key to sort, which is implemented in the compareTo method of ChildVO.
Following is the problem explanation:
Assume there are 4 rows in the ChildVOs' set and it gets displayed in the JSP as follows:
1001
1002
1004
1006
In the JSP using javascript I added fifth row with the value as 1003.
After some manipulation, the list on the JSP looks as:
1001
1002
1003 (new)
1004
1005.
Now, when I iterate the set retrieve from the Hibernate and try to set the new values, I face problem at third row, where I am updating the wrong values.
Can anyone please help on what collection type in Hibernate can be used to overcome this problem?
Following is the mapping documents:
1. ParentVO -->
<hibernate-mapping package="com.entity.hbm">
<class name="com.entity.persistobject.ParentVO"
table="dbo.t_mparent"
dynamic-update="false" dynamic-insert="false">
<cache usage="nonstrict-read-write"/>
<id name="profileNumber" type="int" unsaved-value="any">
<column name="pro_number" sql-type="integer" not-null="true"/>
<generator class="assigned"/>
</id>
<version name="version" type="int" column="version"/>
<set name="children" cascade="all-delete-orphan" inverse="true" sort="natural">
<key column="pro_req_number"/>
<one-to-many class="com.entity.persistobject.ChildVO"/>
</set>
</hibernate-mapping>
2. Child VO -->
<hibernate-mapping package="com.entity.hbm">
<class name="com.entity.persistobject.ChildVO"
table="t_dchildren" lazy="true"
dynamic-update="false" dynamic-insert="false"
polymorphism="explicit">
<cache usage="nonstrict-read-write"/>
<composite-id unsaved-value="any">
<key-many-to-one
name="parentVO"
class="com.entity.ParentVO"
column="pro_number"/>
<key-property name="childNumber" column="pro_child_number"/>
</composite-id>
<version name="version" type="int" column="version"/>
</class>
</hibernate-mapping>
_________________ Thanks In Advance,
Uday
|