ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Commented: (IBATIS-464) iBatis throws a NPE when performing a sub-select in a resultMap.
Date Wed, 03 Oct 2007 17:19:50 GMT

    [ https://issues.apache.org/jira/browse/IBATIS-464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12532170
] 

Jeff Butler commented on IBATIS-464:
------------------------------------

I believe this is a known issue with a simple fix...In your Spring configuration, make sure
that you inject the datasource into the SqlMapClient ONLY - not each DAO.

Please verify that you are only injecting the datasource into the SqlMapClient only and then
report back to us.

> iBatis throws a NPE when performing a sub-select in a resultMap.
> ----------------------------------------------------------------
>
>                 Key: IBATIS-464
>                 URL: https://issues.apache.org/jira/browse/IBATIS-464
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: SQL Maps
>    Affects Versions: 2.2.0, 2.3.0
>         Environment: WinXP, Java 1.5, originally discovered when moving to Spring 2.0.6
(spring-ibatis depends on ibatis 2.3.0)
>            Reporter: Mitchell L. Waters III
>            Priority: Blocker
>
> iBatis throws a NullPointerException when performing a sub-select in a resultMap. 
> For some foo record in the DB, there are a variable number of comments. iBatis allows
the user to return an object that contains the information from the foo table and return the
list/array/collection of related items (comments in this example) from a separate table that
relate to the foo record, using a resultMap like what is listed below.
> <resultMap class="test.FooDto" id="fooResult">
> 	<result property="foo" column="foo" />
> 	<result property="bar" column="bar" />
> 	<result property="comments" select="getCommentList" column="{foo=foo}" />
> </resultMap>
> This works without a hitch in iBatis 2.1.7. However when you attempt to do the same in
iBatis 2.2.0 or 2.3.0, you get a NPE (stack trace to follow). Digging in a bit, it seems that
the session returned to do the SessionScope that is returned for the sub-select is different
than that used to run the original select (different than the behavior in 2.1.7) and that
the transaction/transaction manager for the new SessionScope object is null. It ends up throwing
when it attempts to start a new transaction for the sub-select. 
> I originally saw this problem when updating my application to use Spring 2.0.6 (which
uses iBatis 2.3.0 as a dependency of the spring-ibatis module), but upon further investigation
I was able to isolate it to being in the ibatis-sqlmap module. I've since set up our project
to use Spring 2.0.6 with an older version (2.1.7) of iBatis, and this works fine. While testing
the problem, we tested iBatis 2.1.7, 2.2.0 and 2.3.0 with both Spring 1.2.9 and 2.0.6, and
we only experience the problem with iBatis 2.2.0 and 2.3.0.
> Hopefully, this will be fixed but until then we will be sticking with 2.1.7.
> Thank you,
> Mitch Waters
> org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized
SQLException for SQL []; SQL state [null]; error code [0];   
> --- The error occurred in test.xml.  
> --- The error occurred while applying a result map.  
> --- Check the complexResult.  
> --- Check the result mapping for the 'roles' property.  
> --- Cause: java.lang.NullPointerException; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
  
> --- The error occurred in test.xml.  
> --- The error occurred while applying a result map.  
> --- Check the complexResult.  
> --- Check the result mapping for the 'roles' property.  
> --- Cause: java.lang.NullPointerException
> Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
> --- The error occurred in test.xml.  
> --- The error occurred while applying a result map.  
> --- Check the complexResult.  
> --- Check the result mapping for the 'roles' property.  
> --- Cause: java.lang.NullPointerException
> 	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
> 	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:615)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
> 	at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:269)
> 	at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
> 	at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:220)
> 	at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:267)
> 	at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:261)
> 	at dbtest.UserDao.queryForList(UserDao.java:23)
> 	at dbtest.UserDao.complexQuery(UserDao.java:14)
> 	at dbtest.UserDaoTest.testGetComplexUserList(UserDaoTest.java:43)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at junit.framework.TestCase.runTest(TestCase.java:164)
> 	at junit.framework.TestCase.runBare(TestCase.java:130)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:120)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:230)
> 	at junit.framework.TestSuite.run(TestSuite.java:225)
> 	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.lang.NullPointerException
> 	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:782)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:176)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:154)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:883)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:622)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
> 	at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:95)
> 	at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.getResult(ResultLoader.java:72)
> 	at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.loadResult(ResultLoader.java:59)
> 	at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getNestedSelectMappingValue(BasicResultMap.java:502)
> 	at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResultMap.java:340)
> 	at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:381)
> 	at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:301)
> 	at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:190)
> 	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
> 	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
> 	... 30 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message