I would like to add conditional order by operators to CriteriaBuilder like that: order by rmgtnav_path, rmgtnav_collection_type<>'PROFILE', rmgtnav_denotation asc Or as Order objects:
What the rmgtnav_collection_type<> 'Profile' part does is to resolve the statement as a boolean which is true (1) or false (0) and start sorting with collection_type = Profile on top in my case. Unfortunately, I get an error when calling session.createQuery(cq) method: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: <> near line 1, column 596 [select generatedAlias0 from com.myapp.core.rmgt.rate.business.object.RmgtBVOImpl as generatedAlias0 where ( generatedAlias0.collectionType<>:param0 ) and ( ( generatedAlias0.collectionSubType<>:param1 ) or ( generatedAlias0.collectionSubType is null ) ) and ( ( lower(generatedAlias0.profileStatus) like :param2 ) and ( ( generatedAlias0.type=:param3 ) or ( generatedAlias0.type=:param4 ) ) ) and ( generatedAlias0.enabled=:param5 ) and ( ( generatedAlias0.owner=:param6 ) or ( generatedAlias0.owner=:param7 ) ) order by generatedAlias0.path asc, generatedAlias0.collectionType<>:param8 asc, generatedAlias0.denotation asc] I think it would be beneficial, If criteriaBuilder would also allow to add these kind of statements. |