如何在休眠中为此查询编写条件,
select u.userID, ur.authority from users u, user_roles ur where u.userID = ur.userID and u.userName ="sandy"
我试过这种方式,但我得到一个空列表,
DetachedCriteria ownerCriteria = DetachedCriteria.forClass(users.class);
ownerCriteria.setProjection(Property.forName("userID"));
ownerCriteria.add(Restrictions.eq("userName", "sandy"));
Criteria criteria = session.createCriteria(user_roles.class);
criteria.add(Property.forName("userID").in(ownerCriteria));
System.out.println(criteria.list());
有人可以在这个问题上帮助我吗?