23
mediante criterios de Hibernate, quiero ejecutar el equivalente de:mediante criterios y Proyecciones de Hibernate para seleccionar columnas Distintos múltiples
select distinct uspscity, state from citycomplete where USPSCITY = 'HOUSTON'
pensé haciendo lo siguiente produciría los resultados que quería:
ProjectionList projList = new ProjectionList();
projList.add(Projections.distinct(Projections.property("id.state")));
projList.add(Projections.distinct(Projections.property("id.uspsCity")));
criteria.setProjection(projList);
Pero, en realidad lo que esto hace es ejecutar algo como:
select distinct uspscity, distinct state from citycomplete where USPSCITY = 'HOUSTON'
Lo cual arroja un error, obviamente.
Además de no utilizar Criteria, ¿hay alguna solución para esto?
Gracias,
Brandon
'ProjectionList projList = new ProjectionList();' no es válido, ya que 'ProjectionList()' constructor no es visible. debería ser 'ProjectionList projList = Projections.projectionList();' – destan
Gracias @destan. Arreglé la respuesta. –