• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
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
Pie
Posts: 64620
86
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic