Create an alias for the function in querydsl

How to create a function alias in querydsl , so I can use it in an ORDER BY or GROUP BY statement or in a subquery?

I tried this code:

 StringPath idNiv0s = Expressions.stringPath("idNiv0s"); StringExpression func = Expressions.stringTemplate("replace({0},',','')", Expressions.stringTemplate("substring_index( {0}, ',' , -2 )", ach.ancestors) ); new JPAQuery(entityManager).from(ach) .groupBy(idNiv0s) .orderBy(idNiv0s.desc()) .list(new QCritereItem( func.as(idNiv0s) , idNiv0s.count() )); 

I got this exception

 java.lang.IllegalArgumentException: Undeclared path 'idNiv0s'. Add this path as a source to the query to be able to reference it. 
+4
java hibernate jpa querydsl
source share

No one has answered this question yet.

See similar questions:

7
Returned substring starting from occurrence N

or similar:

3393
Create ArrayList from Array
3044
Creating a memory leak using Java
2240
How to create an executable dependency JAR using Maven?
341
Create the perfect JPA object
4
Undeclared path in QueryDSL
4
Subquery as a field in a query
3
Querydsl needs to query where the integer column is less than the value
one
How to create a dynamic subquery in QueryDsl without using Q classes?
one
How to use an alias in querydsl?
0
What is the root path in QueryDSL? Can you explain by example?

All Articles