0

I have Tables A & B and I join them. I am using JPA with Spring rest. Problem is what table name I am supposed to use to load my search results into.
In normal case if I return results for table A, I can do
public List<A> fun1(){...}
or
public List<B> fun2(){...}
But what do I return as Object type in list if I run a custom join query between unrelated tables?

public List<what?> nativeQueryJoinfun(){....}
Pankaj Sejwal
  • 1,605
  • 1
  • 18
  • 27

1 Answers1

1

There are at least 2 options:

  • Object[]
  • use a projection to DTO

For the second case, see for example: Spring Data JPA map the native query result to Non-Entity POJO

Lesiak
  • 22,088
  • 2
  • 41
  • 65