SpringBoot多表联查
来源:互联网 发布:云计算的具体应用 编辑:程序博客网 时间:2024/06/05 19:17
今天没事,自己瞎搞,玩一下SpringBoot,写一点随笔。
今天在写的时候,遇到了多表查询的问题,网上有好多可以说是好烦,对于习惯了写sql的我来说,简直。。。
好啦,直接分享代码吧。
public interface FieldValueDao extends JpaRepository<FieldValue,Integer> { @Query("select fv from FieldValue fv where field_id IN (select id from Field where table_id=:tableId) ORDER BY field_id") List<FieldValue> getTableValue(@Param("tableId") int tableId);}在这里有一个需要注意的地方select fv from FieldValue fv,这句话不能写成select FieldValue from FieldValue,报错的,原因是作为框架他并不知道你在select后写的是字段名还是表名(鄙人的猜想)。
亲测可用,希望对大家有帮助。
阅读全文
0 0
- SpringBoot多表联查
- springboot
- SpringBoot
- SpringBoot
- springboot
- SpringBoot
- springboot
- SpringBoot
- springboot
- Springboot
- springboot
- SpringBoot
- SpringBoot
- Springboot
- springboot
- springboot
- Springboot
- springboot
- 洛谷 P1438 无聊的数列
- GitBash+GitLab+Eclipse使用攻略非常详细版
- HDU-1846-Brave Game
- 嵌入式Linux中的wpa_supplicant等工具移植
- 高并发和大数据的解决方式
- SpringBoot多表联查
- SSM框架——Spring+SpringMVC+Mybatis的搭建教程
- C语言(字母大小写的转换)
- 小白做今日头条常见问题汇总
- django bug, No module named MySQLdb
- cocos2d-x 、锚点与坐标系详解
- Python3学习(33)--序列和反序列化(二)
- 用户-角色-权限
- 学习笔记之面向对象编程21(数据流、Print流)