JAVA—咖啡館

          ——歡迎訪問rogerfan的博客,常來《JAVA——咖啡館》坐坐,喝杯濃香的咖啡,彼此探討一下JAVA技術,交流工作經驗,分享JAVA帶來的快樂!本網站部分轉載文章,如果有版權問題請與我聯系。

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            447 Posts :: 145 Stories :: 368 Comments :: 0 Trackbacks

          公告

           

          Locations of visitors to this page
          點擊這里給我發消息 點擊這里給我發消息

          常用鏈接

          留言簿(17)

          隨筆分類(542)

          隨筆檔案(438)

          文章分類(182)

          文章檔案(142)

          新聞分類

          ※→ 【JAVA文檔】

          ※→ 【親人博客】

          ※→ 【休閑娛樂】

          ※→ 【友情鏈接】

          ※→ 【學習網站】

          ※→ 【服務網站】

          ※→ 【著名網站】

          ※→ 【阿里博客】

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          目前從實際應用來看,ORM的老大自然是Hibernate,可是iBatis因為相對比較直觀、學習曲線相對較低,因而也贏得了不少用戶的青睞。
          本文主要介紹作為iBatis輔助工具的iBator的使用方法。
          iBator是一個iBatis相關代碼的自動生成工具。
          1、安裝iBator的插件
          在Eclipse中,使用添加站點的方法,輸入網址http://ibatis.apache.org/tools/ibator,進行iBator的安裝。
          2、建議不要直接在使用iBatis的項目里直接使用iBator,推薦另外單獨建立一個項目來生成。比如,建立一個項目叫:IbatorPrj
          3、右鍵點擊IbatorPrj這個項目,如果剛才的插件安裝正確的話,就會看到一個“Add iBATOR to the build path”的選項,點擊一下。
          4、創建iBator的配置文件。下面是我的例子,大家在實際使用的過程中,需要根據自己的情況進行相應的修改。
          主要就是數據庫JDBC庫的路徑、數據庫驅動的類名、項目的名稱、包名等。
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE ibatorConfiguration
            PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN"
            "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd">

          <ibatorConfiguration>
                  <classPathEntry location="c:\javaLibs\MySql\mysql-connector-java-5.0.6-bin.jar" />

                  <ibatorContext id="SampleiBator" targetRuntime="Ibatis2Java5">
                          <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                                  connectionURL="jdbc:mysql://localhost/sample" userId="root" password="admin">
                          </jdbcConnection>

                          <javaTypeResolver>
                                  <property name="forceBigDecimals" value="false" />
                          </javaTypeResolver>

                          <javaModelGenerator targetPackage="com.sample"
                                  targetProject="IbatorPrj\src">
                                  <property name="enableSubPackages" value="true" />
                                  <property name="trimStrings" value="true" />
                          </javaModelGenerator>

                          <sqlMapGenerator targetPackage="com.sample.xml"
                                  targetProject="IbatorPrj\src">
                                  <property name="enableSubPackages" value="true" />
                          </sqlMapGenerator>

                          <daoGenerator type="GENERIC-CI" targetPackage="com.sample.dao"
                                  targetProject="IbatorPrj\src">
                                  <property name="enableSubPackages" value="true" />
                          </daoGenerator>

                          <table schema="sample" tableName="tab1" domainObjectName="JavaBean1">
                                  <property name="useActualColumnNames" value="false" />
                                  <generatedKey column="ID" sqlStatement="MySql" identity="true" />
                          </table>

                  </ibatorContext>
          </ibatorConfiguration>
          5、配置文件生成完畢后,右鍵點擊這個文件,選擇“Generate iBatis Artifact”,然后你就在配置的文件夾下找到自動生成的文件了。

          posted on 2009-11-24 10:26 rogerfan 閱讀(2134) 評論(0)  編輯  收藏 所屬分類: 【開源技術】
          主站蜘蛛池模板: 新巴尔虎右旗| 江达县| 南涧| 措勤县| 白朗县| 兰坪| 商洛市| 兴海县| 子洲县| 合山市| 丰原市| 沈丘县| 安国市| 湛江市| 银川市| 格尔木市| 通州区| 浦城县| 广南县| 湟中县| 固镇县| 化州市| 岱山县| 海盐县| 福安市| 花莲市| 银川市| 化州市| 长泰县| 宝山区| 阿巴嘎旗| 札达县| 厦门市| 贡觉县| 辽中县| 常州市| 嘉鱼县| 兰西县| 金川县| 庄河市| 太和县|