hibernate 执行原生sql,select返回string,long
1.执行sql,返回一个结果集,适用查询一个字段并返回一条记录
3.执行sql,查询单表中多条数据
//尽量避免适用"*"
String sql = "select * from employee e where e.valid=1 and not exists (select employeeid from attendance a where a.employeeid=e.employeeid and a.date = ?)";
SQLQuery query = getSession().createSQLQuery(sql);
query.addEntity(Employee.class).setDate(0, day);
List<Employee> retList = query.list();
4.查询多表
黑色头发:http://heisetoufa.iteye.com/