Myeclipse添加mybatis generator插件
地址:http://mybatis.googlecode.com/svn/sub-projects/generator/trunk/eclipse/UpdateSite/
Myeclipse-help-Myeclipse ConfigurationCenter
在mybatis下右击:Add to profile — pending Changes
MyBatis Generator Generated Java ClientObjects官网:
http://mybatis.org/generator/generatedobjects/javaclient.html
1、 数据库表:
CREATE TABLE IT_USER
(ROW_ID VARCHAR2(15) NOT NULL,
USERNAME VARCHAR2(16),
PWD VARCHAR2(32),
TELEPHONE VARCHAR2(30),
constraint PK_T_SCORE primarykey(ROW_ID)
);
createsequence a_seq --创建序列名字为 a_seq
minvalue1 -- 最小值为 1
maxvalue99999 --- 最大值为 99999
startwith1 --- 开始值 1
incrementby1 ---每次增长值 1
cache100;
INSERTINTOIT_USER(ROW_ID,USERNAME,PWD,TELEPHONE)
VALUES(a_seq.NEXTVAL,'王五','123456','123456789');
select * from IT_USER;
添加generatorConfig.xml,文件内容:
- <?xml version="1.0"encoding="UTF-8" ?>
- <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTDMyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
- <generatorConfiguration >
- <context id="context1">
- <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@192.168.6.40:1521:SIEBELDB"userId="SIEBEL" password="SIEBEL"/>
- <javaModelGenerator targetPackage="com.hand.siebel.pojo" targetProject="Generate\src">
- <property name="enableSubPackages" value="true" />
- </javaModelGenerator>
- <sqlMapGenerator targetPackage="com.hand.siebel.xml" targetProject="Generate\src">
- <property name="enableSubPackages" value="true" />
- </sqlMapGenerator>
- <javaClientGenerator type="XMLMAPPER" targetPackage="com.hand.siebel.dao" targetProject="Generate\src">
- <property name="enableSubPackages"value="true" />
- </javaClientGenerator>
- <table schema="SIEBEL"tableName="IT_USER" domainObjectName="User"
- enableSelectByExample="true"
- enableDeleteByExample="true"
- enableCountByExample="true"
- enableUpdateByExample="true">
- </table>
- </context>
- </generatorConfiguration>
右击generatorConfig.xml,选择生成mybatis