Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

"New to Hibernate" Question - How to fetch only a few fields  RSS feed

 
Andrei Antonescu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am having an object like "Person" (id, name, birthday etc). I want to put all the persons names into a select. For that I only need the name and an ID. How can I fetch only those 2 fields (using HQL)? I have tried like this:



where PersonSelect is just a POJO with a name and an id. It does not work. It says that the constructor can't be found(I have build the constructor in the regular way ...PersonSelect(String name,Long id).... ).

Please help.

Thanks.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
143
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
POJOs need a no-arg constructor.
 
Andrei Antonescu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked. Thank you
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!