Hi Everybody,
I have a complex Oracle Query and very simple class to map with
For example
select a.emp_name, b.dept_name, c.salary_amt from emp a, dept b, salary c where a.emp_no = c.emp_no and a.dept_id = b.dept_id and emp_id in (select emp_id from current_emp);
and
class Employee with attributes (emp_id, emp_name, age, sex, joining_dt, rank, dept_name, salary_amt)
Note that there are several extra attributes in the class
can I write a program like an HQL example shown in "Hibernate In Action" (pg 271)
Iterator i = session.createSQLQuery( select new Employee( a.emp_name, b.dept_name, c.salary_amt ) from emp a, dept b, salary c where a.emp_no = c.emp_no and a.dept_id = b.dept_id and emp_id in (select emp_id from current_emp) )
.list()
.iterator();
while ( i.hasNext() ) {
Employee employee = Employee() i.next() ;
......
}
If it is possible I think I dont even need to do any sort of mapping, even xml mapping.
Regards
Niel
|