// This is the subquery
DetachedCriteria subquery = DetachedCriteria.forClass(Rate.class)
.add(Restrictions.eq("user_id", 55))
.setProjection(Projections.id())
// This corresponds to (SELECT * FROM Unit WHERE id not in (subquery))
Criteria criteria = session
.createCriteria(Unit.class)
.add(Subqueries.notIn("id", subquery));
2条答案
按热度按时间btxsgosb1#
看看您的标记,我认为您需要SQL查询的Criteria视图;所以假设
Unit
和Rate
类:字符串
gc0ot86w2#
我不知道在这种情况下,IN是最合适的。尝试使用内部联接来链接表:
字符串