你的位置:首页 > Java教程

[Java教程]mybatis generator with oracle


1.generator.

<?<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

<generatorConfiguration>
    <classPathEntry location="C:\Users\rocky\.m2\repository\com\oracle\ojdbc6\11.2.0.1.0\ojdbc6-11.2.0.1.0.jar" />

    <context id="MyBatis3" targetRuntime="MyBatis3">
        
        <jdbcConnection driver connectionURL="jdbc:oracle:thin:@192.168.1.5:1521:MYDB"
            userId="rocky" password="rocky">
        </jdbcConnection>
        
        <javaModelGenerator targetPackage="com.myproject.rocky.web.model" targetProject="./src">
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="com.myproject.rocky.web.dao" targetProject="./src">
        </sqlMapGenerator>

        <javaClientGenerator type="            targetProject="./src">
        </javaClientGenerator>
    
        <table tableName="OBJ_USER" schema="rocky" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
    enableSelectByExample="false" selectByExampleQueryId="false">
            <property name="ignoreQualifiersAtRuntime" value="true" />
            <property name="runtimeTableName" value="OBJ_USER" />
            
        </table>
    </context>
</generatorConfiguration>

2.  mybatis-generator-core-1.3.2.jar

3.  java -jar mybatis-generator-core-1.3.2.jar -configfile generator.

4. some problems:

   ~if the table short of primary key, you maynot generate the right mapper file and interface(only has the insert method).