如何从 Spring Boot 中的自定义联接查询中获取结果

问题描述

我有 4 张桌子 它们每个都有实体类、DTO 和存储库

public interface Interface_A extends JpaRepository< Entity_A,Integer> {
      Entity_A findByName(String name);
}

public interface Interface_B extends JpaRepository< Entity_B,Integer> {
      Entity_B findByName(String name);
}

所有这些功能都在 JPA 存储库中正常运行。
但是 当我尝试加入 2 个表时,它说 Carn't create the bean
请插入正确的代码来执行此操作

    public interface Interface_C extends JpaRepository< Entity_A,Integer> {
      Entity_A findByName(String name);

      @Query(value = "SELECT a.name,b.name FROM Entity_A a INNER JOIN Entity_B b ON a.id = b.aid )
      List<Entity_A> getDataFromJoin(); // insert code here 
    }

假设

  1. 两个表与实体同名
  2. Entity_A --> (id,name)
  3. Entity_B --> (id,name,aid)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)