Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

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.

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" />

Posts: 4223
jQuery Eclipse IDE Java
  • 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?
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:
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic