Я пытаюсь найти наибольшую из двух дат в HQL.
В SQL это работает:
SELECT ( GREATEST(a1.startDate, '2019-10-01T00:00:00Z') ) FROM Activity AS a1 WHERE a1.id = 66232
Но эквивалент в HQL выдает мне следующую ошибку:
java.lang.IllegalArgumentException: org.hibernate.QueryException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'GREATEST' {originalText=GREATEST}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[NAMED_PARAM] ParameterNode: '?' {name=param0, expectedType=null}
\-[NAMED_PARAM] ParameterNode: '?' {name=param1, expectedType=null}
[SELECT GREATEST(:param0,:param1) FROM xxx.xxx.xxx.Activity AS a1 WHERE a1.id = :param2]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:133)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164)
... 134 more
Есть ли способ достичь того же, что и в GREATEST () MySQL с двумя датами в HQL?
РЕДАКТИРОВАТЬ: Я также пытался использовать CASE WHEN ... THEN ... ELSE. .. КОНЕЦ, но закончился со следующей ошибкой:
java.lang.IllegalArgumentException: org.hibernate.QueryException: No data type for node: org.hibernate.hql.internal.ast.tree.SearchedCaseNode
\-[CASE] SearchedCaseNode: 'CASE'
+-[WHEN] SqlNode: 'WHEN'
| +-[GT] BinaryLogicOperatorNode: '>'
| | +-[NAMED_PARAM] ParameterNode: '?' {name=param0, expectedType=null}
| | \-[NAMED_PARAM] ParameterNode: '?' {name=param1, expectedType=null}
| \-[NAMED_PARAM] ParameterNode: '?' {name=param2, expectedType=null}
\-[ELSE] SqlNode: 'ELSE'
\-[NAMED_PARAM] ParameterNode: '?' {name=param3, expectedType=null}
[SELECT CASE WHEN :param0 > :param1 THEN :param2 ELSE :param3 END FROM flowzone.model.activity.Activity AS a1 WHERE a1.id = :param4]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:133)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164)
... 138 more