This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS 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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

mapping parent child relationship

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have just started using Hibernate and this forum has helped me in learning many issues on the run. However I am stuck up with one issue.

I have been searching around for a discussion on this issue but havent found anything yet (maybe my searched keywords were not optimum enough)

well I have a table which has a field referring to another field in the same table. For example

Create table emp (
emp_id int,
emp_name varchar(20),
emp_manager int
)

emp_id is the primary field here and the emp_manager is a foreign key refering to emp_id.

In my table.hbm.xml file how should I map this association such that on deleting any emp_id which appears the emp_manager the child fields should also get deleted.

any hints will be appreciated.

thanks
Raaj
 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thing is, this is really a self-referential mapping, not really inheritance, right? The manager is also an employee, so the manager is a row in the employee table, right?

-Cameron McKenzie
 
Raaj Aaryan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you are right, my mistake in word usage. its a recursive relationship .... any hints on the manner in which the mapping file should reflect this relation ?
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic