利用SpringBoot怎么实现一个多表联查功能

这篇文章给大家介绍利用SpringBoot怎么实现一个多表联查功能,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

具体方法如下:

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后写的是字段名还是表名

关于利用SpringBoot怎么实现一个多表联查功能就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。