People 表 --------------- id | --------------- 1 | -------------- Book 表 ----------------------------- id | type | _people_id (Fk) ----------------------------- 1 | 1 | 1 ----------------------------- 2 | 1 | 1 ----------------------------- 3 | 2 | 1 ----------------------------- 4 | 3 | 1 ----------------------------- // People.hbm.xml> // // // // public class People{ private int id; private Set bookSet; public People(){} public People(int id,Set bookSet) { this.id=id; this.bookSet=bookSet; } //getter & setter } //Book.hbm.xml > // public class Book{ private int id; private int type; private People people; public Book(){} //getter & setter } // dao层的方法 根据id获取用户及其 book.type=1的书 public People getPeopleById(int userId,int bookId) { String hql="???????"; return *省略*.uniqueResult(); }
取id=1的用户a,a包含type=1的两本书,hql语句怎么写?谢谢!
欢迎选择我的课程,让我们一起见证您的进步~~