This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Return Multiple entities with different classes

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the following document, i could get how to get Hibernate return Multiple entities. In this example, it's always 2 returning entity but the final result is only one class called "Night.class"

http://docs.jboss.org/hibernate/stable/annotations/reference/en/html/entity.html#entity-mapping-query-native

I have a scenario, where for view only purposes, i need to return Multiple Non-Connected entities (different classes) using same Named Query. I tried following option.



The above scenario did not work. Also the native query need to return only partial set of columns from each table. Not all the columns from each table. I read one possible solution is to use "Projection".

Can you please provide a example, how the mapping should like , for initializing multiple Entity classes having only partial set of columns, using Named/Native Query?

Thanks again in Advance

Edward
 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you'll always get one entity back, but that entity could be associated with other classes. Is that what you mean?

-Cameron McKenzie
 
Edward Rubin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ideal response will be,

ArrayList which holds 2 ArrayList's. One for CustDB1 class and one for TopList class

Thanks
Edward
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!