The reason is u.name is a String. You are no longer getting a User1 object from the query. If you still want to work with User1 objects then you need to use transformation as shown in the example below.
- Hope this helps.
Joined: Apr 04, 2008
Thankyou very much. The program is working.
It works fine if querying from a single table.
How can I write the query to retreive from more than one table(may be 2 or 3) and with parameters? For Example if my query is
session.createQuery("select a.name , b.dept from User as a,department as b where a.DEPT_ID = b.DEPT_ID and a.NAME like ?").setString(0,userName).list();