ProjectionList retorno = Projections.projectionList().create();
retorno.add(Projections.property("a.id"), "id");
retorno.add(Projections.property("a.nome"), "nome");
criteria.setProjection(retorno);
criteria.add(Restrictions.or(Restrictions.eq("a.nome", "Joana"),
Restrictions.eq("a.idade", 56)));
criteria.setResultTransformer(new AliasToBeanResultTransformer(Aluno.class));
Collection
System.out.println(alunos.size());
// CONSOLE:
// select
// this_.id as y0_,
// this_.nome as y1_
// from
// Aluno this_
// where
// (
// this_.nome=?
// or this_.idade=?
// )
}
Nenhum comentário:
Postar um comentário