I just found a way to use the ResultTransformer. Here is a sample of the class that implement this interface:
Code:
public class IDResultTransformer implements ResultTransformer {
public Object transformTuple(Object[] tuple, String[] aliases) {
Object object = tuple[tuple.length - 1];
if(object instanceof MyEntityClass) {
return ((MyEntityClass)object).getID();
}
return object;
}
public List transformList(List collection) {
return collection;
}
Then, instead of invoking the
Code:
criteria.list()
method, there just needs to call
Code:
criteria.setResultTransformer(new IDResultTransformer ()).list();
Xavier.