-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Need Help on loading values from JSP to Set
PostPosted: Tue Mar 22, 2005 7:59 am 
Newbie

Joined: Tue Mar 22, 2005 7:22 am
Posts: 1
Location: India
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 7:43 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
Sounds to me like you should use a Set with sort="natural" so that the objects themselves can be ordered properly while in-memory.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 7:43 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
Using a comparator or the comparable interface, that is.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.