title: Cannot create Typed Query for query with more than one return using request result type
body: <p>I'm trying to bind oracle result list to a <em>summary</em> list. But my <em>summary</em> list has 3 classes defined as entities of DB</p>
  
  <p>I have three entity classes A, B, C</p>
  
  <pre><code>Summary.class
  {
      @Autowired
      private A a;
  
      @Autowired
      private B b;
  
      @Autowired
      private C c;
  
      //getters and setters
  }
  
  @Enity
  class A{
  Fields 1..n ;
  }  // same goes for other classes definition
  </code></pre>
  
  <p>I get the results with following query, but the results cannot be cast to the Summary object </p>
  
  <pre><code>List&lt;Summary&gt; summaryList = entityManager.createQuery("from A a, B b, C c" +
                  " where a.field1 = b.field1 and a.fValue = :fValue " +
                  "and b.field3= c.field3", Summary.class)
                  .setParameter("fValue ", fValue )
                  .getResultList();
  </code></pre>
  
  <p>Debugging:
  I made sure resultslist is not empty and below query works fine if I dont cast it to an object</p>
  
  <pre><code>List summaryList = entityManager.createQuery("from A a, B b, C c" +
                      " where a.field1 = b.field1 and a.fValue = :fValue " +
                      "and b.field3= c.field3")
                      .setParameter("fValue ", fValue )
                      .getResultList();
  </code></pre>
  
  <p>The alternative 1 I see is to iterate through summaryList and assign it them to individual lists like this, which I haven't tested yet but I think it might give a class cast exception since the casting dint work before</p>
  
  <pre><code>for (int i = 0; i &lt; summaryList.size(); i++) {
     Summary s= (Summary) summaryList.get(i); // might be class cast Exception
     aList.add(s.getA());
     bList.add(s.getB());
  }
  </code></pre>
  
  <p>The alternative 2 I'm thinking is to
  get only class A fields list from db cast it to A's List, do it 3 times brute force till I get all of them.</p>
  
  <p>Below are some of questions I looked at before creating a new question</p>
  
  <p><a href="https://stackoverflow.com/questions/10807496/error-cannot-create-typedquery-for-query-with-more-than-one-return">Uses a different class to combine multiple entity classes</a></p>
  
  <p><a href="https://stackoverflow.com/questions/33669774/cannot-create-typedquery-for-query-with-more-than-one-return-using-requested-res">gets a list back mapped to pojo</a></p>
  
  <p>Please let me know your thoughts, I'm thinking my main approach is good way to do it if it works.</p>