我想使用条件获取此 SQL
select A.evaluated_employee_id, A.created_date, A.total_grade
from employee_performance_assessment A
join
( select evaluated_employee_id, max(created_date) as maxdate, status, total_grade
from employee_performance_assessment
group by evaluated_employee_id
) B on A.evaluated_employee_id = B.evaluated_employee_id and A.created_date = B.maxDate
我正在做以下事情
DetachedCriteria dc = DetachedCriteria.forClass(EmployeePerformanceAssessmentBO.class);
dc.createAlias("evaluatedEmployee", "e");
dc.setProjection(Projections.projectionList().add(Projections.max("createdDate"))
.add(Projections.groupProperty("evaluatedEmployee")));
dc.addOrder(Order.asc("e.lastName")).addOrder(Order.asc("createdDate"));
dc.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
return getDAOHibernateTemplate().findByCriteria(dc);
但这会在 WHERE 子句中生成子查询知道如何从同一个表(类)中连接两个条件吗?