Tuesday, November 4, 2014

java.lang.IllegalArgumentException: node to traverse cannot be null!

DetachedCriteria criteria = DetachedCriteria.forClass(Xyz.class);
criteria.setProjection(Projections.projectionList().add(Projections.sqlProjection("  case when approvalImg is null THEN '0' else '1' end as hasApprovalImg", new String[]{"hasApprovalImg"}, new Type[]{StringType.INSTANCE})));
criteria.add(Restrictions.eq("id", id));
criteria.add(Restrictions.ne("deleteFlag", 'Y'));
criteria.setResultTransformer(Transformers.aliasToBean(Xyz.class));    
       return getEntities(criteria.toString());

fix

include select and use database table column name instead approvalImg

criteria.setProjection(Projections.projectionList().add(Projections.sqlProjection("select case when approvalImg is null THEN '0' else '1' end as hasApprovalImg", new String[]{"hasApprovalImg"}, new Type[]{StringType.INSTANCE})));

No comments:

Post a Comment