Java专家能否请您帮我写以下查询作为SQL查询条件查询的一部分。
select A.* FROM AETABLE A where not exists ( select entryid FROM AETABLE B where B.classpk = A.classpk and B.userid = A.userid and B.modifiedDate > A.modifiedDate ) and userid = 10146
您需要编写一个相关的子查询。假设属性/类名称与上面的列/表名称匹配:
DetachedCriteria subquery = DetachedCriteria.forClass(AETable.class, "b") .add(Property.forName("b.classpk").eqProperty("a.classpk")) .add(Property.forName("b.userid").eqProperty("a.userid")) .add(Property.forName("b.modifiedDate").gtProperty("a.modifiedDate")); Criteria criteria = session.createCriteria(AETable.class, "a") .add(Property.forName("userid").eq(new Integer(10146))) .add(Subqueries.notExists(subquery);