-->
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: Mapping
PostPosted: Wed Aug 09, 2006 4:35 pm 
Beginner
Beginner

Joined: Thu Jun 15, 2006 5:31 am
Posts: 21
I just moved the address type from the address table to the person_address table but I dont want to change my classes - only the mapping file.

I have 3 tables:

person (person_id, last_name, ...)
person_address (address_id, address_type, person_id)
address(street, city, ...)

I have 2 classes:

public class Person {
private Set addresses = new HashSet();
private String lastName;
..
}

public class Address
private int addressType;
private String street;
private int city
...
}

Is it possible to modify my mapping file to map the address type? This would allow me to force a unique database constraint on Person /AddressType - which is a common pattern for many tables.

Here is my current mapping from person to addresses

Person.hbm.xml__________
<set name="addresses" table="person_address" cascade="save-update" lazy="false" fetch="join">
<key column="person_id" not-null="true" />
<many-to-many column="address_id"
unique="true" lazy="false" fetch="join"
class="com.project.model.common.AddressModel"/>
</set>


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.