我正在尝试通过hibernate执行此查询。
String queryStr = "from MPRSummaryBean where projId = :projectId and str_to_date(CONCAT('01','-',month, '-',year),'%d-%M-%Y') "
+ "in (select max(str_to_date(CONCAT('01','-',month, '-',year),'%d-%M-%Y')) "
+ "from MPRSummaryBean where projId = :projectId_1 group by projId)";
我收到以下异常。
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'CAST' {originalText=CAST}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[AGGREGATE] AggregateNode: 'max'
| \-[METHOD_CALL] MethodNode: '('
| +-[METHOD_NAME] IdentNode: 'str_to_date' {originalText=str_to_date}
| \-[EXPR_LIST] SqlNode: 'exprList'
| +-[METHOD_CALL] MethodNode: '('
| | +-[METHOD_NAME] IdentNode: 'CONCAT' {originalText=CONCAT}
| | \-[EXPR_LIST] SqlNode: 'exprList'
| | +-[QUOTED_STRING] LiteralNode: ''01''
| | +-[QUOTED_STRING] LiteralNode: ''-''
| | +-[DOT] DotNode: 'mprsummary1_.SUM_MONTH' {propertyName=month,dereferenceType=4,propertyPath=month,path={synthetic-alias}.month,tableAlias=mprsummary1_,className=com.elecnor.mpr.beans.MPRSummaryBean,classAlias=null}
| | | +-[IDENT] IdentNode: '{synthetic-alias}' {originalText={synthetic-alias}}
| | | \-[IDENT] IdentNode: 'month' {originalText=month}
| | +-[QUOTED_STRING] LiteralNode: ''-''
| | \-[DOT] DotNode: 'mprsummary1_.SUM_YEAR' {propertyName=year,dereferenceType=4,propertyPath=year,path={synthetic-alias}.year,tableAlias=mprsummary1_,className=com.elecnor.mpr.beans.MPRSummaryBean,classAlias=null}
| | +-[IDENT] IdentNode: '{synthetic-alias}' {originalText={synthetic-alias}}
| | \-[IDENT] IdentNode: 'year' {originalText=year}
| \-[QUOTED_STRING] LiteralNode: ''%d-%M-%Y''
\-[IDENT] IdentNode: 'DATE' {originalText=DATE}
我试图投出AS DATE,但它没有用,有人可以解释一下为什么这不起作用,并采取措施使这项工作。