Upgrade 3.2.8 to 3.4.1 get NPE on result with collection that uses composite key

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Upgrade 3.2.8 to 3.4.1 get NPE on result with collection that uses composite key

Crater Void
I'm trying to upgrade from mybatis 3.2.8 to 3.4.1.  Getting null pointer exception on a result containing a collection that uses composite keys. The code below worked with 3.2.8.  It also does not work with mybatis 3.3.0 or 3.4.1.

org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in Locations.xml
### The error may involve Mapper.getLocationsWhere
### The error occurred while handling results
### SQL: SELECT DISTINCT A.TTYPE, A.LOCATION, A.YYEAR, A.CLASST, A.SEQU, A.DTE, A.CASETYP, C.CNT, C.CID, C.CSEQ, C.DESCRPT, C.DESCR, C.DESCRT, C.DESCRS, C.DESCRSTS  FROM ADESCRSTBL A        
INNER JOIN CABSTBL C ON A.TTYPE=C.TTYPE AND A.LOCATION=C.LOCATION AND A.YYEAR=C.YYEAR AND A.CLASST=C.CLASST AND A.SEQU=C.SEQU
          WHERE A.LOCATION=12
### Cause: java.lang.NullPointerException
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
    at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:64)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
    at com.sun.proxy.$Proxy0.getLocationsSearch(Unknown Source)
    at rest.Test.main(Test.java:44)
Caused by: java.lang.NullPointerException
    at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(DefaultResultSetHandler.java:411)
    at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:384)
    at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:789)
    at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForNestedResultMap(DefaultResultSetHandler.java:757)
    at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:271)
    at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:246)
    at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:160)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:78)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)
    ... 6 more


XML file:   
   
    <resultMap id="resultLocations" type="Location">
       <result property="ttype" jdbcType="VARCHAR" column="TTYPE" />
        <result property="location" jdbcType="NUMERIC"  column="LOCATION" />
        <result property="yyear" column="YYEAR" />
        <result property="classt" jdbcType="VARCHAR" column="CLASST" />
        <result property="sequ" jdbcType="NUMERIC" column="SEQU" />  
        <result property="dte" jdbcType="NUMERIC" column="DTE" />  
        <result property="casetyp" jdbcType="VARCHAR" column="CASETYP" />
        <collection property="places" column="{TTYPE=TTYPE,LOCATION=LOCATION,YYEAR=YYEAR,CLASST=CLASST,SEQU=SEQU,DTE=DTE,CASETYP=CASETYP}" javaType="ArrayList" ofType="Place"> 
            <result property="cnt" jdbcType="NUMERIC" column="CNT"/>
            <result property="cid" jdbcType="NUMERIC" column="CID"/>
            <result property="cseq" jdbcType="NUMERIC" column="CSEQ"/>
            <result property="descrpt" jdbcType="VARCHAR" column="DESCRPT"/>
            <result property="descr" jdbcType="VARCHAR"  column="DESCR"/>
            <result property="descrt" jdbcType="VARCHAR" column="DESCRT"/>
            <result property="descrs" jdbcType="NUMERIC" column="DESCRS" />
            <result property="descrsts" jdbcType="VARCHAR" column="DESCRSTS"/>
        </collection>
    </resultMap>
   
Configuration:

    <settings>
        <setting name="jdbcTypeForNull" value="NULL"/>
        <setting name="callSettersOnNulls" value="true"/>
    </settings>

Any ideas?
Thanks much

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Upgrade 3.2.8 to 3.4.1 get NPE on result with collection that uses composite key

Iwao AVE!
Hi,

Try removing the 'column' attribute from the 'collection' element.
It is useless for a nested result (see
http://www.mybatis.org/mybatis-3/sqlmap-xml.html).
I'll see if it's possible to raise more appropriate error later.

If it didn't solve the issue, please create SSCCE.
Here are some skeleton projects to make it a little bit easier.
https://github.com/harawata/mybatis-issues

Regards,
Iwao

2016-08-10 2:16 GMT+09:00 Crater Void <[hidden email]>:

> I'm trying to upgrade from mybatis 3.2.8 to 3.4.1.  Getting null pointer
> exception on a result containing a collection that uses composite keys. The
> code below worked with 3.2.8.  It also does not work with mybatis 3.3.0 or
> 3.4.1.
>
> org.apache.ibatis.exceptions.PersistenceException:
> ### Error querying database.  Cause: java.lang.NullPointerException
> ### The error may exist in Locations.xml
> ### The error may involve Mapper.getLocationsWhere
> ### The error occurred while handling results
> ### SQL: SELECT DISTINCT A.TTYPE, A.LOCATION, A.YYEAR, A.CLASST, A.SEQU,
> A.DTE, A.CASETYP, C.CNT, C.CID, C.CSEQ, C.DESCRPT, C.DESCR, C.DESCRT,
> C.DESCRS, C.DESCRSTS  FROM ADESCRSTBL A
> INNER JOIN CABSTBL C ON A.TTYPE=C.TTYPE AND A.LOCATION=C.LOCATION AND
> A.YYEAR=C.YYEAR AND A.CLASST=C.CLASST AND A.SEQU=C.SEQU
>           WHERE A.LOCATION=12
> ### Cause: java.lang.NullPointerException
>     at
> org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
>     at
> org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)
>     at
> org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
>     at
> org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122)
>     at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:64)
>     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
>     at com.sun.proxy.$Proxy0.getLocationsSearch(Unknown Source)
>     at rest.Test.main(Test.java:44)
> Caused by: java.lang.NullPointerException
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(DefaultResultSetHandler.java:411)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:384)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:789)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForNestedResultMap(DefaultResultSetHandler.java:757)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:271)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:246)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:160)
>     at
> org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
>     at
> org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:78)
>     at
> org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
>     at
> org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
>     at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
>     at
> org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
>     at
> org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
>     at
> org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)
>     ... 6 more
>
>
> XML file:
>
>     <resultMap id="resultLocations" type="Location">
>        <result property="ttype" jdbcType="VARCHAR" column="TTYPE" />
>         <result property="location" jdbcType="NUMERIC"  column="LOCATION" />
>         <result property="yyear" column="YYEAR" />
>         <result property="classt" jdbcType="VARCHAR" column="CLASST" />
>         <result property="sequ" jdbcType="NUMERIC" column="SEQU" />
>         <result property="dte" jdbcType="NUMERIC" column="DTE" />
>         <result property="casetyp" jdbcType="VARCHAR" column="CASETYP" />
>         <collection property="places"
> column="{TTYPE=TTYPE,LOCATION=LOCATION,YYEAR=YYEAR,CLASST=CLASST,SEQU=SEQU,DTE=DTE,CASETYP=CASETYP}"
> javaType="ArrayList" ofType="Place">
>             <result property="cnt" jdbcType="NUMERIC" column="CNT"/>
>             <result property="cid" jdbcType="NUMERIC" column="CID"/>
>             <result property="cseq" jdbcType="NUMERIC" column="CSEQ"/>
>             <result property="descrpt" jdbcType="VARCHAR" column="DESCRPT"/>
>             <result property="descr" jdbcType="VARCHAR"  column="DESCR"/>
>             <result property="descrt" jdbcType="VARCHAR" column="DESCRT"/>
>             <result property="descrs" jdbcType="NUMERIC" column="DESCRS" />
>             <result property="descrsts" jdbcType="VARCHAR"
> column="DESCRSTS"/>
>         </collection>
>     </resultMap>
>
> Configuration:
>
>     <settings>
>         <setting name="jdbcTypeForNull" value="NULL"/>
>         <setting name="callSettersOnNulls" value="true"/>
>     </settings>
>
> Any ideas?
> Thanks much
>
> --
> You received this message because you are subscribed to the Google Groups
> "mybatis-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Upgrade 3.2.8 to 3.4.1 get NPE on result with collection that uses composite key

Crater Void
Thanks Iwao.  That worked!


On Tuesday, August 9, 2016 at 11:50:14 AM UTC-6, Iwao AVE! wrote:
Hi,

Try removing the 'column' attribute from the 'collection' element.
It is useless for a nested result (see
<a href="http://www.mybatis.org/mybatis-3/sqlmap-xml.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.mybatis.org%2Fmybatis-3%2Fsqlmap-xml.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGv6NkIzTlaLqSrnPK2gs5RlnGJfg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.mybatis.org%2Fmybatis-3%2Fsqlmap-xml.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGv6NkIzTlaLqSrnPK2gs5RlnGJfg&#39;;return true;">http://www.mybatis.org/mybatis-3/sqlmap-xml.html).
I'll see if it's possible to raise more appropriate error later.

If it didn't solve the issue, please create SSCCE.
Here are some skeleton projects to make it a little bit easier.
<a href="https://github.com/harawata/mybatis-issues" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWLWIlMVmbRMLlHGscVpJTQFca-A&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWLWIlMVmbRMLlHGscVpJTQFca-A&#39;;return true;">https://github.com/harawata/mybatis-issues

Regards,
Iwao

2016-08-10 2:16 GMT+09:00 Crater Void <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="m-7Aw2vfAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">crater...@...>:

> I'm trying to upgrade from mybatis 3.2.8 to 3.4.1.  Getting null pointer
> exception on a result containing a collection that uses composite keys. The
> code below worked with 3.2.8.  It also does not work with mybatis 3.3.0 or
> 3.4.1.
>
> org.apache.ibatis.exceptions.PersistenceException:
> ### Error querying database.  Cause: java.lang.NullPointerException
> ### The error may exist in Locations.xml
> ### The error may involve Mapper.getLocationsWhere
> ### The error occurred while handling results
> ### SQL: SELECT DISTINCT A.TTYPE, A.LOCATION, A.YYEAR, A.CLASST, A.SEQU,
> A.DTE, A.CASETYP, C.CNT, C.CID, C.CSEQ, C.DESCRPT, C.DESCR, C.DESCRT,
> C.DESCRS, C.DESCRSTS  FROM ADESCRSTBL A
> INNER JOIN CABSTBL C ON A.TTYPE=C.TTYPE AND A.LOCATION=C.LOCATION AND
> A.YYEAR=C.YYEAR AND A.CLASST=C.CLASST AND A.SEQU=C.SEQU
>           WHERE A.LOCATION=12
> ### Cause: java.lang.NullPointerException
>     at
> org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
>     at
> org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)
>     at
> org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
>     at
> org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122)
>     at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:64)
>     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
>     at com.sun.proxy.$Proxy0.getLocationsSearch(Unknown Source)
>     at rest.Test.main(Test.java:44)
> Caused by: java.lang.NullPointerException
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(DefaultResultSetHandler.java:411)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:384)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:789)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForNestedResultMap(DefaultResultSetHandler.java:757)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:271)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:246)
>     at
> org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:160)
>     at
> org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
>     at
> org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:78)
>     at
> org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
>     at
> org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
>     at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
>     at
> org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
>     at
> org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
>     at
> org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)
>     ... 6 more
>
>
> XML file:
>
>     <resultMap id="resultLocations" type="Location">
>        <result property="ttype" jdbcType="VARCHAR" column="TTYPE" />
>         <result property="location" jdbcType="NUMERIC"  column="LOCATION" />
>         <result property="yyear" column="YYEAR" />
>         <result property="classt" jdbcType="VARCHAR" column="CLASST" />
>         <result property="sequ" jdbcType="NUMERIC" column="SEQU" />
>         <result property="dte" jdbcType="NUMERIC" column="DTE" />
>         <result property="casetyp" jdbcType="VARCHAR" column="CASETYP" />
>         <collection property="places"
> column="{TTYPE=TTYPE,LOCATION=LOCATION,YYEAR=YYEAR,CLASST=CLASST,SEQU=SEQU,DTE=DTE,CASETYP=CASETYP}"
> javaType="ArrayList" ofType="Place">
>             <result property="cnt" jdbcType="NUMERIC" column="CNT"/>
>             <result property="cid" jdbcType="NUMERIC" column="CID"/>
>             <result property="cseq" jdbcType="NUMERIC" column="CSEQ"/>
>             <result property="descrpt" jdbcType="VARCHAR" column="DESCRPT"/>
>             <result property="descr" jdbcType="VARCHAR"  column="DESCR"/>
>             <result property="descrt" jdbcType="VARCHAR" column="DESCRT"/>
>             <result property="descrs" jdbcType="NUMERIC" column="DESCRS" />
>             <result property="descrsts" jdbcType="VARCHAR"
> column="DESCRSTS"/>
>         </collection>
>     </resultMap>
>
> Configuration:
>
>     <settings>
>         <setting name="jdbcTypeForNull" value="NULL"/>
>         <setting name="callSettersOnNulls" value="true"/>
>     </settings>
>
> Any ideas?
> Thanks much
>
> --
> You received this message because you are subscribed to the Google Groups
> "mybatis-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="m-7Aw2vfAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Upgrade 3.2.8 to 3.4.1 get NPE on result with collection that uses composite key

Iwao AVE!
Glad to know it worked :)
Thanks for the follow-up!

2016-08-10 3:20 GMT+09:00 Crater Void <[hidden email]>:
> Thanks Iwao.  That worked!

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...