• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
reply
    Bookmark Topic Watch Topic
  • New Topic