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.  [ 2 posts ] 
Author Message
 Post subject: Request - Many to One: Restrict # objects AND use Iterable
PostPosted: Fri Jul 07, 2006 2:12 pm 
Beginner
Beginner

Joined: Thu Jun 15, 2006 5:31 am
Posts: 21
I hate to use up a credit on this but I am perplexed with whether I can do exactly this complex mapping - I can only find simple example in books, forums and the net

Requirements
** One person has many addresses **
** Address knows nothing of person **
** Lets keep model/schema sensible: Two classes, two tables **
** One <business, ..etc > has many addresses **

class Person {
private int id;
private String name;
private AddressList addresses;
}

class Address {
private int addressType;
private String street;
}

class AddressList implements Iterable {
private List<Address> list = new List<Address>();
public Iterator<Address> iterator() {
}
}

create table person (
person_id number primary key,
name varchar(30)
)

create table address (
address_id number primary key,
foreign_table_id number,
foreign_table_name varchar(30),
street varchar(255)
)

insert into person (100,'Tim');
insert into address (1,100,'PERSON','166 myavenue')


Is it even possible to map these together???


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 2:59 pm 
Beginner
Beginner

Joined: Thu Jun 15, 2006 5:31 am
Posts: 21
By the way I tried

<set name="addresses">
<key column="person_id"
not-null="true"/>
<one-to-many class="com.myproject.model.common.AddressModel"/>
</set>

but I get

14:54:23,609 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: co
m.myproject.model.patient.PatientModel, setter method of property: addresses
14:54:23,609 ERROR [BasicPropertyAccessor] expected type: com.myproject.model.co
mmon.AddressList, actual value: org.hibernate.collection.PersistentSet
14:54:23,609 WARN [PatientData] com.myproject.model.patient.PatientModel@90fd20


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.