Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to do this?

 
shah rah
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to learn criteria and I want to execute something like

select deptno from dept; //get all deptno

Criteria criteria = session.createCriteria(Dept.class);List objects = criteria.list(); // this is returning all the rows-- deptno and deptname.

Is there a way I can specify in the criteria that its should only fetch all the depno and ignore deptnames?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. You need to use HQL if you want to select individual fields.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!