Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: Collection Mapping on Non-Primary Key

 
B Kuntz
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All, I have what I'm sure is a very basic Hibernate Question. I've hunted diligently for an answer and I've come up blank. I thought I'd post my question here as opposed to the hibernate.org forums since you folks tend to be a little kinder to us newbies!! Anyway...

How do I map a one-to-many association based on something other than the primary key of the parent? I'm working with a legacy system and my child table has no knowledge of the parent. I have zero ability to change either table. My two mapping documents are:


All that's straight forward enough. However, I need to add a collection of children to the parent class. I want to add the following to the Parent mapping:

I realize that the above set is assuming that Child.parentName contains Parent.id. My question is how can I tell the set that it's Parent.widgetName = Child.parentName? Does that make sense?

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic