Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 22420 invoked from network); 11 Apr 2008 02:48:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Apr 2008 02:48:54 -0000 Received: (qmail 83836 invoked by uid 500); 11 Apr 2008 02:48:53 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 83818 invoked by uid 500); 11 Apr 2008 02:48:53 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 83804 invoked by uid 99); 11 Apr 2008 02:48:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Apr 2008 19:48:53 -0700 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2008 02:48:08 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Jk9JM-0007jC-O6 for user-java@ibatis.apache.org; Thu, 10 Apr 2008 19:48:20 -0700 Message-ID: <16624071.post@talk.nabble.com> Date: Thu, 10 Apr 2008 19:48:20 -0700 (PDT) From: nepalon To: user-java@ibatis.apache.org Subject: Problem in resultMap:Cause: java.sql.SQLException: Invalid state, the ResultSet object is closed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: inepalon@163.com X-Virus-Checked: Checked by ClamAV on apache.org There are two class.=EF=BC=9A public class CategoryModel implements Serializable { private int id; private String name; =20 private int parentCategoryId; private CategoryModel parentCategory; // setter/getter ...... } public class SoftwareModel implements Serializable { private int id; private String name; private CategoryModel category; // setter/getter ...... } The xml config file of ibatis: Category.xml Software.xml =20 Use ibatis with springframwork: =20 =20 classpath:properties/cms.properties =20 =20 ${cms.datasource.driverClassName} ${cms.datasource.url} ${cms.datasource.username} ${cms.datasource.password} classpath:cms-sql-map-config.xml =20 PROPAGATION_REQUIRED PROPAGATION_REQUIRED PROPAGATION_REQUIRED PROPAGATION_REQUIRED PROPAGATION_REQUIRED PROPAGATION_REQUIRED =20 This is the class: public abstract class BaseDaoImpl { private SqlMapClientTemplate cmsSqlMapClientTemplete; public SqlMapClientTemplate getCmsSqlMapClientTemplete() { return cmsSqlMapClientTemplete; } public void setCmsSqlMapClientTemplete( SqlMapClientTemplate cmsSqlMapClientTemplete) { this.cmsSqlMapClientTemplete =3D cmsSqlMapClientTemplete= ; } } public class SoftwareDaoImpl extends BaseDaoImpl implements SoftwareDao { @Override public SoftwareModel getSoftwareById(int softwareId) { return (SoftwareModel) getCmsSqlMapClientTemplete().queryForObject("Software.getSoftwareById", new Integer(softwareId)); } @Override public SoftwareModel getSoftwareByName(String name) { return (SoftwareModel) getCmsSqlMapClientTemplete().queryForObject("Software.getSoftwareByName", name); } } public class CategoryDaoImpl extends BaseDaoImpl implements CategoryDao { @Override public CategoryModel getCategoryById(int categoryId) { return (CategoryModel) getCmsSqlMapClientTemplete().queryForObject("Category.getCategoryById", new Integer(categoryId)); } =20 @Override public CategoryModel getCategoryByName(String name) { return (CategoryModel) getCmsSqlMapClientTemplete().queryForObject("Category.getCategoryByName", name); } } Under code will cause throwing exception show in the end: SoftwareModel model =3D softwareDao.getSoftwareById(111);//throw exception SoftwareModel model =3D softwareDao.getSoftwareByName("aaa");// throw exception If I remove the config =E2=80=9C=E2=80=9D in the file Category.xml.Th= e code will not throw exception. But curiously, the code =E2=80=9CCategoryModel model =3D categoryDao.getCategoryById(273)=E2=80=9D will not throw exception. It is the stack with exception: org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [HY010]; error code [0]; = =20 --- The error occurred in com/demo/software/Software.xml. =20 --- The error occurred while applying a result map. =20 --- Check the Software.softwareResult. =20 --- Check the result mapping for the 'category' property. =20 --- Cause: com.ibatis.common.jdbc.exception.NestedSQLException: =20 --- The error occurred in com/demo/category/Category.xml. =20 --- The error occurred while applying a result map. =20 --- Check the Category.categoryResult. =20 --- The error happened while setting a property on the result object. =20 --- Cause: java.sql.SQLException: Invalid state, the ResultSet object is closed.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: =20 --- The error occurred in com/demo/software/Software.xml. =20 --- The error occurred while applying a result map. =20 --- Check the Software.softwareResult. =20 --- Check the result mapping for the 'category' property. =20 --- Cause: com.ibatis.common.jdbc.exception.NestedSQLException: =20 --- The error occurred in com/demo/category/Category.xml. =20 --- The error occurred while applying a result map. =20 --- Check the Category.categoryResult. =20 --- The error happened while setting a property on the result object. =20 --- Cause: java.sql.SQLException: Invalid state, the ResultSet object is closed. at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(S= QLStateSQLExceptionTranslator.java:124) at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.transla= te(SQLErrorCodeSQLExceptionTranslator.java:322) at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTem= plate.java:212) at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapCl= ientTemplate.java:271) at com.shareweb.cms.component.software.dao.impl.ibatis.SoftwareDaoImpl.getSoft= wareById(SoftwareDaoImpl.java:23) at com.shareweb.cms.importdata.AdvertExcelImportManagerImplTest.testImportData= (AdvertExcelImportManagerImplTest.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3= 9) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp= l.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) 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:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3= TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:= 38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR= unner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR= unner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner= .java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunne= r.java:196) Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: =20 --- The error occurred in com/demo/software/Software.xml. =20 --- The error occurred while applying a result map. =20 --- Check the Software.softwareResult. =20 --- Check the result mapping for the 'category' property. =20 --- Cause: com.ibatis.common.jdbc.exception.NestedSQLException: =20 --- The error occurred in com/demo/category/Category.xml. =20 --- The error occurred while applying a result map. =20 --- Check the Category.categoryResult. =20 --- The error happened while setting a property on the result object. =20 --- Cause: java.sql.SQLException: Invalid state, the ResultSet object is closed. at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWith= Callback(MappedStatement.java:201) at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForO= bject(MappedStatement.java:120) at com.ibatis.sqlmap.engine.mapping.statement.CachingStatement.executeQueryFor= Object(CachingStatement.java:79) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapE= xecutorDelegate.java:518) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapE= xecutorDelegate.java:493) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessio= nImpl.java:106) at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlM= apClientTemplate.java:273) at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTem= plate.java:209) ... 21 more Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: =20 --- The error occurred in com/demo/category/Category.xml. =20 --- The error occurred while applying a result map. =20 --- Check the Category.categoryResult. =20 --- The error happened while setting a property on the result object. =20 --- Cause: java.sql.SQLException: Invalid state, the ResultSet object is closed. at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWith= Callback(MappedStatement.java:201) at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForO= bject(MappedStatement.java:120) at com.ibatis.sqlmap.engine.mapping.statement.CachingStatement.executeQueryFor= Object(CachingStatement.java:79) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapE= xecutorDelegate.java:518) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapE= xecutorDelegate.java:493) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessio= nImpl.java:106) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientI= mpl.java:82) at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.getResult(Resul= tLoader.java:75) at com.ibatis.sqlmap.engine.mapping.result.loader.LazyResultLoader.loadResult(= LazyResultLoader.java:77) at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.loadResult(Resu= ltLoader.java:54) at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getNestedSelectMappingVal= ue(ResultMap.java:501) at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getResults(ResultMap.java= :341) at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.ja= va:384) at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExe= cutor.java:300) at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.jav= a:189) at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(= MappedStatement.java:221) at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWith= Callback(MappedStatement.java:189) ... 28 more Caused by: java.sql.SQLException: Invalid state, the ResultSet object is closed. at net.sourceforge.jtds.jdbc.JtdsResultSet.checkOpen(JtdsResultSet.java:299) at net.sourceforge.jtds.jdbc.JtdsResultSet.next(JtdsResultSet.java:569) at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:1= 69) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3= 9) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp= l.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.ibatis.common.jdbc.logging.ResultSetLogProxy.invoke(ResultSetLogProxy.j= ava:47) at $Proxy10.next(Unknown Source) at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.ja= va:383) at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExe= cutor.java:300) at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.jav= a:189) at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(= MappedStatement.java:221) at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWith= Callback(MappedStatement.java:189) ... 44 more --=20 View this message in context: http://www.nabble.com/Problem-in-resultMap%3A= Cause%3A-java.sql.SQLException%3A-Invalid-state%2C-the-ResultSet-object-is-= closed-tp16624071p16624071.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com.