Forums Register Login

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

+Pie Number of slices to send: Send
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.

+Pie Number of slices to send: Send
POJOs need a no-arg constructor.
+Pie Number of slices to send: Send
That worked. Thank you
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1206 times.
Similar Threads
How to select a row in a Jtable?
jsp:usebean
Regarding JPA Select Query
jpa problem
Fetch only one column using hibernate 3.0
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:16:04.