• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to access the fields of result of named query ?

 
Csaba Szegedi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • 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.
 
Alberto Ivo
Ranch Hand
Posts: 39
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic