• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

entity loading blues

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got this scenario:
a query from wich i need to return a list of beans, that i don't want persisted.

The question is:
Can i do that directly speifying the bean like:

w/o having to map the Person to a table?

Closest answer for that from what i found is the one below, but i need to know the answer to the above question, it makes the following solution redundant.
EDIT: shortest question would be: how can i externalize a named query w/o an entity, and also map the result set to a bean with the least configuring possible.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the only way to populate non-entity beans is to use Transformers.aliasToBean() it seems. BTW, it only accepts the column name, not an alias of it. It only needs matching type with the bean fields / public accesor methods.

Otherwise externalizing a SQL query, is as simple as:


and registering it in the hibernate config file.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seeing your posting I blogged about how to do this in EclipseLink here: http://onpersistence.blogspot.com/2010/07/eclipselink-jpa-native-constructor.html

--Shaun
 
reply
    Bookmark Topic Watch Topic
  • New Topic