I have a problem mapping the following in Hibernate 3.1.3.
We have 1 user table. This table has a relation to 1 of 3 tables to create a join with another of 3 tables and to determine the type (spare me I didn't come up with that solution :) ).
Currently to retrieve a user we chech the 3 tables to see in which of the tables the user is present and retrieve the record from the desired table. Which isn't a big problem for retrieving 1 user, but when retrieving 100s of records it is a problem.
Schematic representation
Code:
/ employee type 1 join table --- employee type1 data table
[USER]------ employee type 2 join table --- employee type2 data table
\ employee type 3 join table --- employee type3 data table
Currently I'm trying to find a solution to place this in the mapping. However I seem not be able to come up with a solution which is managable by Hibernate.
I would like to create a view from all the tables, containing the userId and employee type, and then use the employee type as the discriminator to retrieve the correct employee. However I seem not to be able to specify a select different from the mapping.
Any suggestions would be helpful.