0

I'm getting the following error

Error Querying database. cannot invoke "Object.hashCode()" because "key" is null

  1. stack trace:

org.mybatis.spring.MyBatisSyste Exception: nested
    exception is org.apache.ibatis.exceptions.Pers istenceException:
    ### Error querying database. Cause: java.lang. NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null
    ### The error may exist in class path resource [SbmtMapper.xml]
    ### The error may involve com.delta.crew.dao.mapper.Subm itMapperlfc.getRotnAndLegs
    ### The error occurred while handling results
    ### SQL: WITH ROTATIONS AS (SELECT OP.EMPL ID AS usrld. 'SBMT' AS opType, OVER NB AS version

UNION ALL SELECT RTN.*
FROM ROTATIONS RTN
### Cause: java.lang.NullPointerException: Cannot invoke "Obiect.hashCode(" because "key" is null
at com.delta.crew .dao .SubmitDaolmp-getRotnAndLegs(SubmitDaolmp.java:52) ~[main/:?]
at com delta.crew da SubmitDaolmp$$FastClassBySpringCGLIB$Sd3034a58,.invoke(<generated>)~[main/:?]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)~[spring-core-5.3.10.jar:5.3.101
at
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
~[spring-aop-5.3.10.jar:5.3.101
at org.springframework.aop.framework.ReflectiveMethodinvocation.proceed(ReflectiveMethodinvocation.java:163)~
[spring-aop-5.3.10.jar:5.3.101
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)~

The error may exist in some mybatis mapper.xml and the error occurred while handling the results of the below SQL query. The SQL query has null values set.

Example :

Mapper

<resultMap id = "rotsMap" type = SubmitPojo">
<result column="ROTATION_ID" property = "rots_id" />
<result column="ARRIVAL_TIME" property = "arrTime" />
<result column="SBMT_ID" property ="sbmt_id>

Select statement

<select id="getRots" resultMap="rotsMap">
SELECT NULL AS ROTATION_ID
NULL AS ARRIVAL_TIME
OP.SBMT_ID AS SBMT_ID
FROM ROTATION OP;
</select>

I tried setting all the mappings correctly. I'm not sure what went wrong

ip1234
  • 1
  • 2
  • Please add the full stack trace to the question. And what does "The SQL query has null values set" mean? Does it mean that there are null columns in the result set? – ave Jan 31 '23 at 06:05
  • @ave Hi, I have added the stack trace, and yes, it has columns with null values -thanks! – ip1234 Jan 31 '23 at 14:19
  • 1
    Is that the entire stack trace? Stack trace usually includes the call stack (class name, method name, line number, etc.). And the SQL in the stack trace is different from the one that you posted (it starts with `WITH ROTATIONS ...`). It might be better if you create and share a small demo project (like [these](https://github.com/harawata/mybatis-issues)) that allows us to reproduce the exception you are experiencing. – ave Jan 31 '23 at 14:31

0 Answers0