1.iBATIS 의 설정을 도와주는 ibator(구 abator) 설치
http://ibatis.apache.org/ibator.html
Eclipse Plugin
Take the "Help>Software Updates..." Menu Option
- Select the "Available Software" Tab
- Press the "Add Site" button
- Enter the following information:
Location: http://ibatis.apache.org/tools/ibator - Press OK
- Check the box next to "Apache iBATIS Ibator Feature"
- Press the "Install" button
- Follow the remainder of the install wizard
ibator 플러그인 설치
설정파일을 만들어보자
New > Other > Apache iBATIS Ibator > Apache iBATIS Ibator Configuration file 을 선택한다.
설정파일의 저장경로와 파일명 설정
생성된 ibatorConfig.xml 파일내용
<?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="C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar"/>
<ibatorContext id="context1" >
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@127.0.0.1:1521:XE" userId="javauser" password="dkdlxl" />
<javaModelGenerator targetPackage="net.bit.lecture.board.vo" targetProject="JDK_015_IBATOR/src" />
<sqlMapGenerator targetPackage="net.bit.lecture.board.dao" targetProject="JDK_015_IBATOR/src" />
<daoGenerator targetPackage="net.bit.lecture.board.dao" targetProject="JDK_015_IBATOR/src" type="GENERIC-CI" />
<table schema="JAVAUSER" tableName="TB_BOARD" domainObjectName="Board" >
</table>
</ibatorContext>
</ibatorConfiguration>
<classPathEntry> : ojdbc jar 파일의 물리경로이다.
<jdbcConnection> : 데이타베이스 드라이버 및 계정정보 설정
<javaModelGenerator> : src 폴더 내부에 모델 클래스를 가지는 bean을 생성한다. 'targetPackage'에 bean이
생성될 패키지명을 기입하고, targetProject에는 프로젝트 명을 기입한다
<sqlMapGenerator> : 생성될 매핑 파일의 저장 경로설정
<daoGenerator> : iBATIS를 사용하는 DAO 클래스 bean을 생성한다
<table> : 데이타베이스 스키마, 테이블정보 설정
schema="DB계정" tableName="테이블명" domainObjectName="여기에 등록된이름으로 모델bean이 생성된다"
만약 다른 테이블에 대한 iBATIS설정이 필요하다면 <ibatorContext id="context1" >의 id를 다르게하여 추가해 주면된다.
config파일 설정 후 config.xml파일을 우클릭하면 아래와 같이 Generate iBATIS Artifacts 를 선택할 수 있다.
Generate iBATIS Artifacts를 클릭하면 domainObjectName으로 등록된 이름으로 DAO Interfase 파일과 DAO Interface를 상속한 DAO 클랙스, DB계정+테이블명+sqlMap.xml이름으로된 매핑파일, 모델bean(VO) 파일등이 자동 생성된다.


0