■ Data Skill ■/MyBatis

[iBatis] iBatis 소스 생성 툴 ibator의 간단한 사용법

한길(One Way) 2023. 2. 25.

 

ibator 란

  • 아파치 재단에서 만든 데이터맵핑 프레임워크인 iBatis를 위한 소스 생성 툴
  • 생성 소스 (테이블 단위로 기본적인 insert,update,delete,select 관련소스)
    • SqlMap XML Files
    • Java Classes to match the primary key and fields of the table
    • DAO Classes

 

Eclipse plugin 설치

  1. Take the "Help>install new software..." Menu Option
  2. Press the "Add" button
  3. Enter the following information: Location: http://ibatis.apache.org/tools/ibator
  4. Press OK
  5. Check the box next to "Apache iBATISIbator Feature"
  6. Press the "Install" button
  7. Follow the remainder of the install wizard


ibatorConfig.xml(소스 생성 설정파일) 만들기

마우스 오른쪽 키 -- new -- other 선택

 

 

생성된 파일

<?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>
       <ibatorContext id="context1">
             <jdbcConnection driverClass="???" connectionURL="???" userId="???" password="???" />
             <javaModelGenerator targetPackage="???" targetProject="???" />
             <sqlMapGenerator targetPackage="???" targetProject="???" />
             <daoGenerator targetPackage="???" targetProject="???" type="GENERIC-CI" />
             <table schema="???" tableName="???">
                    <columnOverride column="???" property="???" />
             </table>
       </ibatorContext>
</ibatorConfiguration>

 

수정된 파일

<?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="D:\MyIDE\LIB\jdbc\oracle\ojdbc6.jar" />
       <!-- <ibatorContext id="CT_COMM_CD_DESC" > 
              <jdbcConnection driverClass="oracle.jdbc.OracleDriver" connectionURL="dburl" userId="user" password="pass" /> 
              <javaModelGenerator targetPackage="database.model" targetProject="dwmsc" /> 
              <sqlMapGenerator targetPackage="database.dao.sqlmap" targetProject="dwmsc" /> 
              <daoGenerator targetPackage="database.dao" targetProject="dwmsc" type="GENERIC-CI" /> 
              <table schema="ACNT" tableName="CT_COMM_CD_DESC" enableSelectByExample="false" enableDeleteByExample="false"
                    enableCountByExample="false" enableUpdateByExample="false"/> 
       </ibatorContext> -->
       <ibatorContext id="AT_ACNT">
             <jdbcConnection driverClass="oracle.jdbc.OracleDriver" connectionURL="dburl" userId="user" password="pass" />
             <javaModelGenerator targetPackage="database.model" targetProject="dwmsc" />
             <sqlMapGenerator targetPackage="dao.sqlmap" targetProject="dwmsc" />
             <daoGenerator targetPackage="database.dao" targetProject="dwmsc" type="GENERIC-CI" />
             <table schema="ACNT" tableName="AT_ACNT" enableSelectByExample="false" 
                     enableDeleteByExample="false" enableCountByExample="false" enableUpdateByExample="false" />
       </ibatorContext>
</ibatorConfiguration>

 

소스 파일 생성

 

728x90

댓글