Я написал этот метод запроса весной:
@Query("SELECT MAX(TO_NUMBER(ban.codiBanca)) FROM DBanche ban WHERE LENGTH(TRIM(TRANSLATE(ban.codiBanca, '0123456789', ' '))) IS NULL")
public BigDecimal getMaxCodiBanca();
Тип поля codiBanca - VARCHAR (20).
При запуске приложения я получаю эту ошибку:
Caused By: java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.math.BigDecimal it.gov.mef.efim.dao.repository.base.BancaDao.getMaxCodiBanca()!
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:92)
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:62)
at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:72)
at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromQueryAnnotation(JpaQueryFactory.java:53)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:136)
Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.AggregateNode
\-[AGGREGATE] AggregateNode: 'MAX'
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'TO_NUMBER' {originalText=TO_NUMBER}
\-[EXPR_LIST] SqlNode: 'exprList'
\-[DOT] DotNode: 'dbanche0_.CODI_BANCA' {propertyName=codiBanca,dereferenceType=PRIMITIVE,getPropertyPath=codiBanca,path=ban.codiBanca,tableAlias=dbanche0_,className=it.gov.mef.efim.dao.entities.DBanche,classAlias=ban}
+-[ALIAS_REF] IdentNode: 'dbanche0_.SEQU_ID_BANCA' {alias=ban, className=it.gov.mef.efim.dao.entities.DBanche, tableAlias=dbanche0_}
\-[IDENT] IdentNode: 'codiBanca' {originalText=codiBanca}
Как я могу исправить эту ошибку?