java - hibernate5.06,两实体关系为双向多对一,一端对象取特定的多端对象,hql如何写?
天蓬老师
天蓬老师 2017-04-17 17:49:10
0
0
243
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语句怎么写?谢谢!

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all (0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!