-->
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.  [ 2 posts ] 
Author Message
 Post subject: Table per subclass / Multi-level Hierarchy
PostPosted: Sat Jan 17, 2009 8:41 pm 
Newbie

Joined: Sat Jan 17, 2009 8:06 pm
Posts: 3
Location: Montreal
Hello,

I have some issues with multi-level hierarchy mapping using the "Table per subclass" strategy.

Here is the list of the db tables I am trying to map using the "Table per Subclass" strategy:

4 Tables:

USER (Abstract Superclass)

EMPLOYEE (USER Subclass)

CUSTOMER (USER Subclass)

MANAGER (EMPLOYEE Subclass)

Following the principles of ERM, I should have this approach since I will need to associate MANAGER, CUSTOMER, and EMPLOYEE instances to different types of relationships table mapping them to other other entities.

I tried the "Table per Subclass" strategy from the Hibernate reference manual, and I got it to work. However, once I added a relationship to EMPLOYEE, I encountered problems. Basically, I was unable to add a <join> statement to the EMPLOYEE mapping file.

Apparently <joined-subclass> does not like <join>, hence, what am I suppose to use in replacement of <join>???

The db schema is as follows:

EMPLOYEE * == 1 EMPLOYEE_DEPARTMENT * == 1 DEPARTMENT

That is, EMPLOYEE_DEPARTMENT is a many-one relationship between the two entities EMPLOYEE and DEPARTMENT.


I tried to resolve this problem with the "Table per subclass, using a discriminator" strategy and it worked. But I had to add a discriminator to the tables. Is there any other way to accomplish this without having to deal with discriminators?

_________________
Thanks,
Arturo


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 9:12 am 
Newbie

Joined: Sat Jan 17, 2009 8:06 pm
Posts: 3
Location: Montreal
Some clarification:

The db schema is as follows (I made a mistake in the previous post):

EMPLOYEE * == EMPLOYEE_DEPARTMENT == 1 DEPARTMEN

the schema is:

(Note * denotes primary key)

EMPLOYEE(userId*, firstName, lastName, etc)

EMPLOYEE_DEPARTMENT(userId*, deptId)

DEPARTMENT(deptId*, name, etc)

Hence, EMPLOYEE_DEPARTMENT is a many-to-one mapping from EMPLOYEE to DEPARTMENT.

However, keep in mind that my question is not a DB question but rather a Hibernate mapping question. How can this mapping be done within the <joined-subclass> mapping file of EMPLOYEE?

_________________
Thanks,
Arturo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.