我必须使用子查询为实体B(实体A作为字段)为实体A制定标准。为了避免缓存未命中,我必须拒绝基于id的查询。
这是伪代码示例
DetachedCriteria criteriaA = (criteria for A)....
DetachedCriteria bCriteria = DetachedCriteria.forClass(B.class);
bCriteria.add(Restrictions.eq(".....));
bCriteria.add(Restrictions.ge(....));
bCriteria.setProjection(Projections.property("A"));
Criterion criterion = Subqueries.in("A entity", bCriteria);//here i want to refer to entity A
criteriaA.add(criterion);