-->
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: Embedded & AttributeOverrides Limitations
PostPosted: Mon Mar 05, 2007 9:06 pm 
Newbie

Joined: Tue Oct 24, 2006 9:21 pm
Posts: 12
I have a problem trying to create a mapping for the following model:

Person
Address homeAddress
Address workAddress


Address
@Embedded Street street
String city
String country


We need to store the address inlined to the Person Table so our initial thought was to make the Address @Embeddable.

e.g.

@Entity
Person {
@Embedded Address homeAddress
@Embedded Address workAddress

}


The issue is that there will be no distinction between
say a homeAddressCity or a workAddressCity. So again our solution was to have something like this:

@Entity
Person {

@Embedded
@AttributeOverrides({
@AttributeOverride( name="homeAddressCity", column=@Column(name="city") ),
@AttributeOverride( name="homeAddressCountry", column=@Column(name="country") )
})
Address homeAddress

@Embedded
@AttributeOverrides({
@AttributeOverride( name="workAddressCity", column=@Column(name="city") ),
@AttributeOverride( name="workAddressCountry", column=@Column(name="country") )
})
Address workAddress

}


But it doesn't appear like you can modify the mapping for the @Street from the Person Entity. Can you suggest an alternative to this or a solution to our problem?
Thanks very much.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 07, 2007 8:39 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@AttributeOverride( name="homeAddress.street.name", column=@Column(name="home_street_name") ),

_________________
Emmanuel


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.