0
hibenate標準如何寫標準,該查詢在冬眠,如何實現相等利用hbm.xml文件中
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());
有人能幫我解決這個問題嗎?