• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mapping parent child relationship

 
Raaj Aaryan
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
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic