Hello!
I want to make this query in HQL but i get an exception. In mySQL database the query returns the expected result so the sintax is ok... maybe there is some slight difference in HQL. Help would be much appreciated! Here it is:
Code:
String result = (String) session.createQuery("select m.mwoid from Mwo m " + "where timestampdiff(second, m.creationDate, now()) = (select min(timestampdiff(second, m.creationDate, now())) from Mwo m)")
.uniqueResult();
return result;
The exception is:
Code:
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.AggregateNode
\-[AGGREGATE] AggregateNode: 'min'
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'timestampdiff' {originalText=timestampdiff}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[IDENT] IdentNode: 'second' {originalText=second}
+-[DOT] DotNode: 'mwo1_.CreationDate' {propertyName=creationDate,dereferenceType=4,propertyPath=creationDate,path=m.creationDate,tableAlias=mwo1_,className=pt.inescporto.kobas.maintenance.persistenceLayer.Mwo,classAlias=m}
| +-[ALIAS_REF] IdentNode: 'mwo1_.MWOID' {alias=m, className=pt.inescporto.kobas.maintenance.persistenceLayer.Mwo, tableAlias=mwo1_}
| \-[IDENT] IdentNode: 'creationDate' {originalText=creationDate}
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'now' {originalText=now}
\-[EXPR_LIST] SqlNode: 'exprList'