Sunday, May 1, 2011

Hibernate criteria _ how to use criteria to return only one element of an object instead the entire object

Hello,

I'm trying to get only the list of id of object bob for example instead of the list of bob. It's ok with a HQL request, but I would know if it's possible using criteria ?

An example :

final StringBuilder hql = new StringBuilder();
hql.append( "select bob.id from " )
    .append( bob.class.getName() ).append( " bob " )
    .append( "where bob.id > 10");

final Query query = session.createQuery( hql.toString() );
return query.list();
From stackoverflow

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.