• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

how to access the fields of result of named query ?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

How can access the fields of the named query ?

I have a named query :



Which kind of object list must be created to store the result ?

Thanks in advance.
 
Ranch Hand
Posts: 39
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the resultList method returns a List of objects.
If you do a cast, it returns a list of whatever you want

It will return a list of users.. If you want just the id and date.. You could do a UserVO object (for example). somthing like this:

And put this constructor in your query.

I hope it helps.
ivo.
 
Csaba Szegedi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Alberto,
I wanted to avoid this approach, one way or another it seems to be more elegant than other (if i want to get back more than one field)

In the end, i narrowed the query to one result field (user_id)

Thanks for your effort.

Cs.


Alberto Ivo wrote:the resultList method returns a List of objects.
If you do a cast, it returns a list of whatever you want

It will return a list of users.. If you want just the id and date.. You could do a UserVO object (for example). somthing like this:

And put this constructor in your query.

I hope it helps.
ivo.

 
BWA HA HA HA HA HA HA! Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic