我需要有关将带subQuery的sql查询转换为休眠条件的帮助。 sql查询为:
select * from project_table where project_id in (select project_id from user_projects where user_id = '5')
我尝试过这种方法,但是没有用:
DetachedCriteria projectUser = DetachedCriteria.forClass(UserProjects.class)
.setProjection(Projections.property("project_id"))
.add(Restrictions.eq("project_id", id));
return session.createCriteria(Project.class)
.add( Subqueries.propertyIn("my_project_id", projectUser) )
.list();