-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Creating subclass based on foreign key lookup
PostPosted: Mon Oct 31, 2005 12:04 pm 
say i got two tables

employee
empid
name
RoleID

and

employeeRoles
RoleID
roleType

I would like to create a subclass eg. called manager (roletype=manager) with the same properties as employee
how would the mapping file look like ?

David


Top
  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 4:26 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
AFAIK, you can't use subclass without a discriminator-value column in your employee table.

But joined-subclass might work here...
(for more details, read Inheritance Mapping)

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 5:28 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
If you can't alter the tables you should map employeeRoles to a separate class and define an association between them. this design is more flexible because allows an employee to have more than one role (i think this also happens in real life...)

Radu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.