关于Hibernate多对多映射的关联属性查询
java吧
全部回复
仅看楼主
level 5
飘走红尘 楼主
有一个多对多的映射,三张表
书本表 b_id b_name b_price
分类表 c_id c_name
中间表 b_id c_id
通过Hibernate生产实体类和映射文件
Book{
int id;
String name;
double price;
Set categories;
}
Category{
int id;
String name;
Set books;
}
现在有这样一个要求 希望通过页面选择一个分类和价格,查询出所有符合条件的书本
对应的hql语句要怎么写?
2013年07月09日 08点07分 1
level 8
select bc.book from Bc bc where bc.category.id=? and bc.book.price=?
2013年07月09日 09点07分 2
太谢谢啦
2013年07月09日 11点07分
level 5
bc是什么
2013年07月09日 11点07分 3
bc是中间表
2013年07月09日 12点07分
1