-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: help : Native SQL & (HQL example in Hibernate in Action)
PostPosted: Fri Oct 21, 2005 8:11 am 
Newbie

Joined: Tue Oct 18, 2005 2:51 am
Posts: 14
Location: Chennai, India
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.