I'm trying to use hibernate and projection to result a list that doesn't have duplicated element.
I have a class CurrEntityProfileBO, it has property entityId.
Criteria criteria = session.createCriteria(
CurrEntityProfileBO.class, "entityProfileBO");
criteria.setProjection(Projections.distinct(Projections
.projectionList().add(Projections.property("entityId"))));
I'm getting a exception:
[2014-11-04 11:28:59] ERROR [http-8080-5] (SqlExceptionHelper.java:144) - ORA-01791: not a SELECTed expression
[2014-11-04 11:28:59] WARN [http-8080-5] (AbstractHandlerExceptionResolver.java:185) - Handler execution resulted in exception
org.hibernate.exception.SQLGrammarException: ORA-01791: not a SELECTed expression
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82)
appreciated any helps!
according to sp00m. criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); works very well!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.