tx = session.beginTransaction(); List results=session.find("from HourlyEmployee"); tx.commit(); return results; 在运行Session的find()方法时,Hibernate执行以下select语句: select * from EMPLOYEES where EMPLOYEE_TYPE='HE' ; select * from COMPANIES where ID=1;
在加载HourlyEmployee对象时,还会同时加载与它关联的Company对象。
(2)运行findAllEmployees()方法,它的代码如下:
tx = session.beginTransaction(); List results=session.find("from Employee"); tx.commit(); return results; 在运行Session的find()方法时,Hibernate执行以下select语句: select * from EMPLOYEES; select * from COMPANIES where ID=1;