本机SQL结果作为休眠POJO

时间:2014-02-22 05:48:35

标签: java mysql sql hibernate

我有一个子查询

select * 
  from Employee 
 where employeeId in (
              select employeeId 
                from dept as x 
               where x.name ='Dept1' 
                     and x.category ='category1' 
                     and x.employeeId IN (
                                  select employeeId 
                                    from dept as x 
                                   where x.name ='Dept2' 
                                         and x.category ='category2'))

我想选择返回列表作为员工POJO对象。

我正在使用hibernate。

由于

1 个答案:

答案 0 :(得分:0)

以下代码对我有用。

session.createSQLQuery(query).
      addEntity("employee",Employee.class).
      setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).
      list();

由于