-->
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: Multiple component collection mapping
PostPosted: Thu Aug 05, 2004 3:32 pm 
Newbie

Joined: Wed May 12, 2004 10:24 am
Posts: 11
Greetings all. I am currently stumped by mapping problem for our domain model..

/**
* @hibernate.class table="LISTING_ITEM"
*/
class ListingItem extends Componet{
/**
* @hibernate.component class="Content"
* /
Content title;
/**
* @hibernate.component class="Content"
* /
Content content;
}

class Content {
/**
* @hibernate.map name="localizedContent" cascade="all"
* @hibernate.collection-index column="locale"
* @hibernate.collection-key column="FK_parent"
* @hibernate.collection-one-to-many class="LocalizedContent"
*/
Map localizedContent;
}

/**
* @hibernate.class table="LOCALIZED_CONTENT"
*/
class LocalizedContent extends Component{
/**
* @hibernate.property column="locale"
*/
String locale
/**
* @hibernate.property column="locale"
*/
String content
}

Component handles IDs for all persistent classes.

Now, when I save items, everything is well- no errors or anything. However when I load the item back in from the db, ListingItem.title contains the same information as ListingItem.content. I understand now why this is- they both have the same FK. Now, my question is, how do I get around this? I realize that I could make Content an entity; however I would like to avoid that if possible- would prefer not to have a table that is empty except for ID. Any other way to make this mapping scenario work?

Beyond this, how would you map two different collections of the same object to different fields of one entity? I would think this problem would be the same if I eliminated Content and just had 2 maps of LocalizedContent inside ListingItem.

Thanks in advance for your help.


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.