【问题标题】:JPA Returning Table name in case of join of unrelated tablesJPA在不相关表连接的情况下返回表名
【发布时间】:2019-04-27 14:20:18
【问题描述】:

我有 A 和 B 表,我加入了它们。我正在将 JPA 与 Spring 休息一起使用。问题是我应该使用什么表名来加载我的搜索结果。
在正常情况下,如果我返回表 A 的结果,我可以执行
public List<A> fun1(){...}

public List<B> fun2(){...}
但是,如果我在不相关的表之间运行自定义联接查询,我会在列表中作为对象类型返回什么?

public List<what?> nativeQueryJoinfun(){....}

【问题讨论】:

    标签: hibernate spring-data-jpa


    【解决方案1】:

    至少有2个选项:

    • 对象[]
    • 使用投影到 DTO

    对于第二种情况,例如: Spring Data JPA map the native query result to Non-Entity POJO

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-03
      • 2022-06-30
      • 2010-11-25
      • 2012-01-13
      • 2022-07-01
      • 2018-05-09
      • 2012-04-12
      • 1970-01-01
      相关资源
      最近更新 更多