I was trying to translate an SQL query to hibernate. But the problem is with the mapping. I have a class named UserBean to which values from different table is required. So I don�t know how to map this UserBean class, as there is no table in my data base that corresponds to UserBean. The properties in UserBean needs to get values from three tables, named
1. seat_user_alloted
allot_Id (primary,autoincrement),
seat_Id,
user_Id,
active_Date,
deactive_Date,
active_Status,
passwd
2. user_setup
user_Id(primary,autoincrement),
employee_Id,
user_Name,
active_Date,
deactive_Date,
active_Status,
user_Code
3. hierarchy_setup
hierarchy_Id (primary,autoincrement),
hierarchy_Name,
hierarchy_Code,
hierarchy_Level,
parent_hierarchy,
hierarchy_Tree,
active_Date,
deactive_Date,
active_Status,
category,
allot_Status
The query that I need to translate is shown below
select
seat_user_alloted.seat_Id as seatId,
seat_user_alloted.user_Id as userId,
hierarchy_setup.hierarchy_Name as seatName,
hierarchy_setup.hierarchy_Code as seatCode,
user_setup.user_Code as empCode,
user_setup.user_Name as empName
from
user_setup,hierarchy_setup,seat_user_alloted
where
seat_user_alloted.user_Id=user_setup.user_Id
and
seat_user_alloted.seat_Id=hierarchy_setup.hierarchy_Id
and
user_setup.active_Status='Y'
and
hierarchy_setup.active_Status='Y'
and
seat_user_alloted.active_Status='Y'
note: In the select query above� that table-column-values are got in to the UserBean which contains the properties given below with getter and setters.
UserBean
private
String seatId;
private String userId;
private String seatName;
private String seatCode;
private String empCode;
private String empName;
private String userOffice;
private String userManager;
private String userSection;
Now how can I map this user bean to three tables� or please some one post a solution.
[ November 19, 2008: Message edited by: Arun G Nair ]
[ November 19, 2008: Message edited by: Arun G Nair ]