Trying to achieve the following result with QueryDSL:
select id, identifier
from eip_transportcode_message
order by
case
when identifier REGEXP '^[[:digit:]]+$'
then cast(identifier as signed)
else identifier end,
LENGTH(identifier) ASC;
Tried the following code:
PathBuilder path = new PathBuilder(TransportCode.class, "transportCode");
StringPath regexPath = Expressions.stringPath("REGEXP '^[[:digit:]]+$'");
StringPath property = orderByExpression.getString(o.getProperty());
Expression identifierTarget = path
.when(regexPath)
.then(property.castToNum(Integer.class))
.otherwise(property);
The outcome is:
order by case when transportCode = REGEXP '^[[:digit:]]+$' then cast(transportCode.identifier as integer) else...
The Problem is the "=" in front of REGEXP and the missing "transportCode.identifier".