-->
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: trying to fill a static array ([]) with <array> mappin
PostPosted: Mon Dec 05, 2005 6:18 pm 
Newbie

Joined: Wed Sep 28, 2005 12:24 am
Posts: 15
Hi there,

I am trying to fill an array with child objects in a db table and having no luck. The problem is I dont have a field in the database table that is zero-based so the <list-index> is pointing just to the primary key in the child table. Problem is it is not zero based per parent.

Here is the problem. Person has an array of Addresses.

class Person{

private int personid;
Address [] addresses;

}

class Address {

private int addressId;
private int personId;

}

My mapping is:

<class="Person">

<array name="addresses"
cascade="all-delete-orphan">
<key column="personId"/>
<list-index column="id"/>
<one-to-many class="com.company.Address"/>
</array>

</class>

<class="Address">

<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>

<property name="personId" type="integer" insert="false" update="false">
<column name="personId" not-null="true" />
</property>

</class>


The problem, again, is that the <list-index> will be something like 4578 for the child address row. I get an arrayindexoutofboundsexception of course.

How can i make this work?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 05, 2005 7:54 pm 
Newbie

Joined: Wed Sep 28, 2005 12:24 am
Posts: 15
bueller?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2005 1:45 pm 
Newbie

Joined: Wed Sep 28, 2005 12:24 am
Posts: 15
bump...


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.