-->
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.  [ 1 post ] 
Author Message
 Post subject: getting data from a collection
PostPosted: Wed Jun 09, 2004 11:34 am 
Newbie

Joined: Tue Sep 16, 2003 10:38 am
Posts: 3
I am using the one to many mapping between two tables

<bag name="details" cascade="all">
<key column="vod_vtr_id"/>
<one-to-many class="org.youthnet.doit.domain.VolunteerDetails"/>
</bag>

In the second mapping

<id name="detailsId" type="long" unsaved-value="0">
<column name="vod_vtr_id" sql-type="number" not-null="true"/>
<generator class="foreign"/>
<param name="property">volunteer</param>-
</generator>
</id>

<property name="detailsLKTId">
<column name="vod_lkt_id" sql-type="number" not-null="true"/>
</property>
<property name="detailsLKPId">
<column name="vod_lkp_id" sql-type="number" not-null="true"/>
</property>

<many-to-one name="volunteer" column="vod_vtr_id" insert="false" update="false"/>

The code to pull out the data from the collection

Collection col = vol.getDetails();
Iterator iter = col.iterator();
VolunteerDetails vd = new VolunteerDetails();
while(iter.hasNext())
{

vd = (VolunteerDetails) iter.next();
System.out.println("vod id = " + vd.getDetailsId());
System.out.println("lkt id = " + vd.getDetailsLKTId());
System.out.println("lkp id = " + vd.getDetailsLKPId());
}

The resulting output gets me the correct number of objects from the database but the data in the collection is duplicated.

To get the correct data do i need to have a unique key(sequence). As a test i added a column to the database which had unique id's and then i got the correct information.

However is there a way to get the correct data without doing this?

Any help will be appreciated

Oli


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

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.