Hi All,
I am having two tables as below
1> Employee( emp_id, dept_id, emp_name, salary)
emp_id as Pk
dept_id as Fk
2> Department(dept_id, dept_name)
dept_id as Pk
And the corresponding java classes are
1> Employee
int empId;
int deptId;
String empName;
int salary;
2> Department
int deptId;
String deptName;
Set employees;
Now as you see a department can have many employees. And if i use the hibernate to generate OM(object models) for "Employee" and "Department" i can just put "one-to-many" relationship in employee.hbm.xml file for the class Department, which i know can be done and is fine, but for some weired reasons i have to use "Stored Procedures" here i can use "Sql-query" and just call that procedure inside (Only if i have to represent one class at a time say Department) for this i can provide mappings such that each column i am returning will get mapped to one property of the Department class using "<return-property>" of a "Sql-query". but when relationship of the Employee to the Department comes i have no idea what to do (Please help me!) .
I wanted the OM's for each employee should get generate for the corresponding department so that the generated OM's for Employees will have reference for the OM of Department (i do not want to write any extra code here) just as what happens when we specify "one-to-many" relationship tag in hbm.xml file and make a call to Department and have access to Employee objects inside it.
Thanx in advance
Yuwaraj
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: