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.
|