假设现在有两张表student和class,class有一个name字段,student和class之间是单向many-to-many的关系:
在student里面有一个List:classList(在class里面没有关联student对象),关联此学生所选择的课程。
现在有一个查询,在student的业务类里需要根据课程名来查询此学生说选择的课程,此时可以这样:
select * from student stu where stu.classList.name like '%"+name+"%' .
这样hibernate就会自动去转换每个对象,配置这个名称。

相关文章:

  • 2022-01-05
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2021-11-30
  • 2021-10-01
  • 2021-06-26
猜你喜欢
  • 2022-01-14
  • 2022-12-23
  • 2022-01-01
  • 2021-04-21
  • 2021-12-08
  • 2022-12-23
  • 2021-04-07
相关资源
相似解决方案