Beginner |
|
Joined: Mon Apr 04, 2011 3:31 am Posts: 41
|
Hey Try this ..
Query query = session.createQuery("from Admin admin inner join Customer cust where cust.Name ='Niks'"); query.addEntity(Admin.class); query.setInteger("username",'"niks'); List =query.list();
This is an native SQL query so you can run it in MySQL query browser for example. You don't use the objects that wrap the tables in the query so any column names are actual table column names and not the names used for the columns in the object. eg cust_id instead of custId. You must define the class to map result to with addEntity. You can define multiple classes as well.
This works like a charm. It is better for maintainability to define this as a named query in the hbm.xml file
_________________ Thanks Niki
|
|