• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

id/parent_id fields on same table. Is it possible to map?

 
Cris Sanchez
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I really tried to find this issue, but I'm not sure if it was post before. So...

I wanna make an association one-to-many on fields into same table. Eg.

TableCategory
ID --- PARENTID --- NAME
1 0 Books
2 1 Admin. Books
3 2 Marketing Books

Is it possible?

I try to do this via code below, but I'm getting the following error: "Same logical column name referenced several times"

<class name="Category" ...>
<set name="childCategories">
<key column="parent_id" not-null="true" />
<one-to-many class="Category" />
</set>

Thanks,
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm more of a JDO person than a Hibernate person, but I'd like to know if this is possible either. I tried searching google, and the only suggestion I found was to implement it via joins in the mapping, but having not worked with Hibernate, I'm not sure how well this works. Anyone every do self mappings before?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this in Hibernate? I've been playing around with the examples in Hibernate In Action, and I have a similar reflexive example that works with no problems:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic