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
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.
I think single pojo solution is not possible here. Hope , following solution will help i your case.
Create pojo for each table like for user_setup create pojo having all column in that table, same for hierarchy_setup , And while creating pojo for seat_user_alloted add object of user_setup pojo and hierarchy_setup pojo.
well thanks for your suggestion Kuldeep!!! But doing so.. how shall I get values, and to which object I will get that... Actually in ibatis this is not an issue, because we can directly assign the values from different tables to a single class.
But I think, working in hibernate also, this kind of issue will come again and again... so could you please explain the solution in detail, if possible..