Im using SPRING JPA in my application and trying to run a native query as follows:
@Query (value="select max(ts) from abc.test s \n" +
"where abc.getTest(s.user_id) = :#{#userId} \n" +
"and upper(app_name) = 'TAX' and INSTR(s.user_id, '.') > 0 \n" +
"group by user_id, app_name", nativeQuery=true)
Timestamp getLastLogin(BigDecimal userId);
I am getting exception as follows:
Caused by: Error : 932, Position : 110, Sql = select max(ts) from abc.test s
where ac.getTest(s.user_id) = :1
and upper(app_name) = 'TAX' and INSTR(s.user_id, '.') > 0
group by user_id, app_name, OriginalSql = select max(ts) from abc.test s
where abc.getTest(s.user_id) = ?
and upper(app_name) = 'TAX' and INSTR(s.user_id, '.') > 0
group by user_id, app_name, Error Msg = ORA-00932: inconsistent datatypes: expected NUMBER got BINARY
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:514)
... 109 more
<org.hibernate.engine.jdbc.spi.SqlExceptionHelper> <SqlExceptionHelper> <logExceptions> <SQL Error: 932, SQLState: 42000>
<org.hibernate.engine.jdbc.spi.SqlExceptionHelper> <SqlExceptionHelper> <logExceptions> <ORA-00932: inconsistent datatypes: expected NUMBER got BINARY
>
I tried to convert the max(ts) to string using to_char and changed the coresponding getter/setter to String still getting the same issue.
Update: I fixed it with this small change
String getLastLogin(@Param("userId") BigDecimal userId); Didnt add @Param for the arguments.
abc.getTestreturn?