Pessoal estou com o seguinte problema, tenho uma “Composite Key” chave composta e preciso limitar os campos de retorno
ja fiz isso usando:
criteria.setProjection(Projections.projectionList().add(Projections.property("field"))....)
Até ai funcionou legal na outra consulta que precisei fazer, mas agora tenho um @EmbeddedId
e não consigo fazer…
Alguem sabe oque preciso fazer ?
OBS: Preciso limitar a quantidade de fields pois essa tabela tem 90 fields … modelagem horrivel, eu sei, banco legado :?
[Editado]
Aqui esta minha criteria:
Criteria c = getSession().createCriteria(Cliente.class);
c.add(Restrictions.eq("cdFilial", cdFilial));
c.add(Restrictions.eq("cdVendedor", cdVendedor));
c.setProjection(Projections.projectionList()
.add(Projections.property("clientePK.cdCliente"))
.add(Projections.property("clientePK.cdFilial"))
);
c.setResultTransformer(Transformers.aliasToBean(Cliente.class));
Exception:
Hibernate: select this_.CD_CLIENTE as y0_, this_.CD_FILIAL as y1_ from CLIENTE this_ where y1_=? and this_.CD_VENDEDOR=?
org.hibernate.exception.GenericJDBCException: could not execute query
Column unknown
Y1_
At line 1, column 81.
Vejam que CD_FILIAL no where esta como y1_ :roll: