Hallo forum,
when calling following nethod:
Code:
public Integer retrieveHighestBatchImportNumberForCustomer(String customerCode) {
Integer highestNumber = null;
String queryString = "select max(to_number(h.batchNum)) from BatchImportHistory as h where h.licNum=?";
List<Integer> resultList = getHibernateTemplate().find(queryString, customerCode);
if (resultList != null && resultList.size() > 0 && resultList.get(0) != null) { // Last check is important as we use MAX(...) that might return <NULL>
logger.info("Highest batch import number: "+resultList.get(0));
highestNumber = resultList.get(0);
}
return highestNumber;
}
I'm getting following error:
Code:
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.AggregateNode
\-[AGGREGATE] AggregateNode: 'max'
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'to_number' {originalText=to_number}
\-[EXPR_LIST] SqlNode: 'exprList'
\-[DOT] DotNode: 'batchimpor0_.BATCH_NUM' {propertyName=batchNum,dereferenceType=4,propertyPath=batchNum,path=h.batchNum,tableAlias=batchimpor0_,className=de.ls.spwebonline.model.domain.BatchImportHistory,classAlias=h}
+-[ALIAS_REF] IdentNode: 'batchimpor0_.ID' {alias=h, className=de.ls.spwebonline.model.domain.BatchImportHistory, tableAlias=batchimpor0_}
\-[IDENT] IdentNode: 'batchNum' {originalText=batchNum}
has anybody any idea what I'm doing wrong?
The same statement executed as SQL has no problems:
Code:
select max(to_number(BATCH_NUM)) bn from BATCH_IMPORT_HISTORY model where model.LIC_NUM='ROLAND'
Many thanks in advance!
Giorgi