我愛(ài)oo,我愛(ài)java

          交流blog QQ:421057986 oofrank@donews

          使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案


          1:abator下載:http://ibatis.apache.org/abator.html
          2:將abator安裝到eclipse中
          3:此時(shí)可以新建一種文件類型:Abator for iBATIS Configuration File,建立一個(gè)
          4:在 jdbcConnection 中設(shè)置要mapping的數(shù)據(jù)庫(kù)的jdbc連接
            classPathEntry 是你的jdbc driver類路徑
          5:javaModelGenerator,sqlMapGenerator,daoGenerator 分別設(shè)置 java dataObject、sql mapping文件和 DAO 接口、實(shí)現(xiàn)類的生成位置:targetPackage 目標(biāo)包,targetProject:eclipse項(xiàng)目
          6:daoGenerator 中可以設(shè)置屬性  type: ibatis 或 spring 指定生成的dao實(shí)現(xiàn)類是使用com.ibatis.dao.client.template.SqlMapDaoTemplate
          還是
          org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
          7: table 中 tableName 指定要處理的表名
            可以有多個(gè)table
          8:table中可以包含子元素 generatedKey: 使Insert方法可以返回值--由指定的column mapping
          9:generatedKey中的sqlStatement屬性可以是獲取sequence的SQL,也可以是獲取自增值的SQL
            比如:Oracle的 select theSequence.nextVal from dual
                 SQLServer的 SELECT @@IDENTITY as  column_name
          10:保存文件,選中文件,右鍵菜單選擇Generate iBATIS Artifacts! ok...



          使用abtor生成的iBatis代碼出現(xiàn)xml解析錯(cuò)誤的解決方案
          如果按上述方式生成的代碼有xml解析錯(cuò)誤:  請(qǐng)下載這個(gè)

          注意,該文件名為Abator.rar.txt實(shí)際是一個(gè)rar文件,只是上傳服務(wù)器有文件類型限制 所以只好加了擴(kuò)展名txt。
          請(qǐng)去掉.txt后解壓。

          使用
          org.apache.ibatis.abator.core_0.5.1.jar
          替換調(diào)你的 eclipse\plugins 的同名文件 即可。

          然后重新生成代碼。 OK 應(yīng)該可以咯....

          我改了一點(diǎn)代碼,需要可以留言。

          posted on 2006-01-21 13:51 兼聽則明 閱讀(9080) 評(píng)論(12)  編輯  收藏 所屬分類: java

          評(píng)論

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2006-03-28 21:12 andyking

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE abatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"
          "http://ibatis.apache.org/dtd/abator-config_1_0.dtd">

          <abatorConfiguration>
          <abatorContext> <!-- TODO: Add Database Connection Information -->
          <jdbcConnection driverClass="net.sourceforge.jtds.jdbc.Driver"
          connectionURL="jdbc:jtds:sqlserver://localhost:1433/test;tds=8.0;lastupdatecount=true"
          userId="sa"
          password="">
          <classPathEntry location="D:/tools/driver/jtds-1.2.jar" />
          </jdbcConnection>

          <javaModelGenerator targetPackage="com.ibatis" targetProject="." />
          <sqlMapGenerator targetPackage="com.ibatis.sqlmap" targetProject="." />
          <daoGenerator type="IBATIS" targetPackage="com.ibatis" targetProject="." />

          <table schema="" tableName="dbo.user_property">
          <generatedKey sqlStatement="SELECT @@IDENTITY as column_name" identity="true" column=""/>
          </table>

          </abatorContext>
          </abatorConfiguration>

            回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2006-03-28 21:14 andyking

          Generation Warnings Occured
          Table dbo.user_property does not exist, or contains only LOB fields
          請(qǐng)問(wèn)大哥這是什么原因!明明數(shù)據(jù)庫(kù)里面有這張表!為什么不能生成!  回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2006-03-29 09:28 oofrank

          @andyking
          <table schema="" tableName="dbo.user_property">
          改成
          <table schema="dbo" tableName="user_property">
          試試

          我看你的沒(méi)什么問(wèn)題  回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2006-06-13 13:33 tedeyang

          我也碰到過(guò)xml解析錯(cuò)誤的現(xiàn)象。后來(lái)發(fā)現(xiàn)是ibatis的配置中沒(méi)有打開namespace這個(gè)選項(xiàng),要這樣
          <sqlMapConfig>
          <settings
          useStatementNamespaces="true"
          />
          ...
          不知道你指的錯(cuò)誤是不是類似的情況?

          另外,我不太明白abator自動(dòng)生成的xxxExample類和xxxselectByExample()怎么使用,能貼一段示例代碼嗎?

          期待您的回信:tedeyang@msn.com  回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2006-12-03 17:56 houya

          對(duì)于字段數(shù)不是很多的表abator生成的xml文件包含insert update select 等方法。
          而對(duì)于字段數(shù)很多的表,abator確只能生成resultMap和動(dòng)態(tài)條件,其他的insert和update等都沒(méi)有。請(qǐng)問(wèn)這是為什么啊。  回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2007-09-19 17:11 china_world

          ORA-00604: error occurred at recursive SQL level 1
          ORA-12705: Cannot access NLS data files or invalid environment specified

          ORA-00604: error occurred at recursive SQL level 1
          ORA-12705: Cannot access NLS data files or invalid environment specified

          請(qǐng)問(wèn)這個(gè)如何解決啊 謝謝!!

            回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2009-08-20 18:09 fieldwolf2

          myeclipse連接oracle出現(xiàn)ora-12705錯(cuò)誤的解決辦法: MyEclipse DB Brower建立oracle數(shù)據(jù)庫(kù)連接的時(shí)候,報(bào)出下面的錯(cuò)誤. java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 java.sql.SQLException: ORA-12705: invalid or unknown NLS parameter value specified 修改eclipse\eclipse.ini中的-Duser.language=*保持與windows XP控制面板中"區(qū)域和語(yǔ)言選項(xiàng)"中選定的語(yǔ)言區(qū)域一至; 如:將"-Duser.language=en"修改為"-Duser.language=zh"
            回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2014-06-25 21:58 個(gè)

          個(gè)  回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2015-03-24 14:26 陳春熖

          The specified target project directory fgms_easyui does not exist  回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2015-04-02 10:25 generation warning occured

          Run complete With Warning
          Reasion:
          generation warning occured這個(gè)是怎么回事?  回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案 2016-03-08 18:52 趙國(guó)棟

          我生成成功了。可是當(dāng)我想 拼寫 WHERE *** OR *** 的時(shí)候,我找不到相關(guān)的方法。只有
          is null
          not is null
          =
          >=
          <=
          等一些 工具方法。并且他們都是 and 的關(guān)系。
          請(qǐng)樓主看到后賜教。!謝謝了。  回復(fù)  更多評(píng)論   

          # re: 使用abator自動(dòng)生成ibatis代碼的經(jīng)驗(yàn) 及碰到的問(wèn)題的解決方案[未登錄](méi) 2016-08-03 11:27 minmin

          請(qǐng)問(wèn)下:自動(dòng)生成的時(shí)候 生成java文件和sqlMap文件少了個(gè)字段是怎么回事,  回復(fù)  更多評(píng)論   

          主站蜘蛛池模板: 泗洪县| 镇安县| 松原市| 邳州市| 南投县| 板桥市| 搜索| 石嘴山市| 蒙城县| 诸暨市| 阿坝| 阳西县| 额尔古纳市| 睢宁县| 彝良县| 乌兰浩特市| 同江市| 乐至县| 班玛县| 如皋市| 淄博市| 电白县| 宜兰县| 垣曲县| 长乐市| 登封市| 团风县| 丰都县| 随州市| 天等县| 四川省| 建水县| 札达县| 乌什县| 屏东市| 江门市| 芜湖县| 慈利县| 开原市| 册亨县| 临海市|