使用Hibernate的条件,我想执行以下操作:
select distinct uspscity, state from citycomplete where USPSCITY = 'HOUSTON'
我认为执行以下操作将产生想要的结果:
ProjectionList projList = new ProjectionList(); projList.add(Projections.distinct(Projections.property("id.state"))); projList.add(Projections.distinct(Projections.property("id.uspsCity"))); criteria.setProjection(projList);
但是,这实际上是执行类似以下操作:
select distinct uspscity, distinct state from citycomplete where USPSCITY = 'HOUSTON'
显然,这引发了错误。
除了不使用条件以外,还有解决方案吗?
谢谢,
布兰登
ProjectionList projList = Projections.projectionList(); projList.add(Projections.property("id.state")); projList.add(Projections.property("id.uspsCity")); criteria.setProjection(Projections.distinct(projList));