乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      ibatis

       wtf_soft 2006-04-19
      從昨天下午到現(xiàn)在,一直在進(jìn)行ibatis環(huán)境下的單元測試,在測試中發(fā)現(xiàn)了一個(gè)奇怪的現(xiàn)象。
      我們知道在sqlMap的insert語句中,一般需要一個(gè)bean類來作為parameterClass的值,一般
      來說,這個(gè)bean只要一些簡單的get/set方法就可以了,但是在測試中卻發(fā)現(xiàn)這樣一個(gè)問題:
      如果該bean類繼承java.util.ArrayList,那么這時(shí)再進(jìn)行sqlMapClient的insert則會(huì)報(bào)錯(cuò)。
      (當(dāng)然了,如果不繼承java.util.ArrayList類就不會(huì)出錯(cuò),繼承其它類也不會(huì)出錯(cuò))
      下面將出現(xiàn)錯(cuò)誤的環(huán)境數(shù)據(jù)列出來:
      1,sqlMap

      <insert id="simpleObjectTest" parameterClass="com.smartdot.galaxy.portal.resources.test.IbatisTestObject">
              insert into zhangbo_test (id,name
              values(#id#,#name#)
      </insert>
      2,IbatisTestObject?.java

      public class IbatisTestObject extends ArrayList {

          private String id;
          private String name;
          public IbatisTestObject() {
              super();
          }
          public String getId() {
              return id;
          }
          public void setId(String id) {
              this.id = id;
          }
          public String getName() {
              return name;
          }
          public void setName(String name) {
              this.name = name;
          }
      }
      3,junit test

              ...
              IbatisTestObject obj=new IbatisTestObject();
              obj.setId("33");
              obj.setName("55");
              sqlMap.insert("simpleObjectTest",obj);
              ...
      4,數(shù)據(jù)庫中字段id,name均為varchar2

      5,出錯(cuò)信息


      com.ibatis.common.jdbc.exception.NestedSQLException:   
      --- The error occurred in com/smartdot/galaxy/portal/resources/test/resources_sql_map.xml.  
      --- The error occurred while preparing the mapped statement for execution.  
      --- Check the simpleObjectTest.  
      --- Check the parameter map.  
      --- Cause: java.lang.NumberFormatException: For input string: "i"
      Caused by: java.lang.NumberFormatException: For input string: "i"
          at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:90)
          at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:442)
          at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:85)
          at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:57)
          at com.smartdot.galaxy.portal.resources.test.ResourcesSqlMapTest.insertIbatisSimpleObj(ResourcesSqlMapTest.java:84)
          at com.smartdot.galaxy.portal.resources.test.ResourcesSqlMapTest.test(ResourcesSqlMapTest.java:48)
          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:324)
          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.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
      Caused by: java.lang.NumberFormatException: For input string: "i"

             (更多略)

      所以建議大家不要在Ibatis中的bean不要繼承java.util.ArrayList,而是使用復(fù)合模式。

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多