zoukankan      html  css  js  c++  java
  • mybatis generator--逆向工程工具的使用

    先附上官方网址:http://www.mybatis.org/generator/

    Mybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由于手动书写很容易出错,我们可以利用Mybatis-Generator来帮我们自动生成文件。

    其次,mybatis generator 只适用于单表查询。mybatis-gennerator插件自动生成mybatis所需要的dao、bean、mapper xml文件,能够极大的提升工作效率,几乎不用再自己写sql语句,实现项目中的增删改查。

    主要介绍在oracel数据库中,配置文件的书写。

    <?xml version="1.0" encoding="UTF-8"?>
    <!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="D:j2eeidejdbclibojdbc7.jar" />-->
    <context id="context1" targetRuntime="MyBatis3">
    <!-- 禁用mybatis插件自动生成的注释 -->
    <commentGenerator>
    <property name="suppressDate" value="true" />
    <property name="suppressAllComments" value="true" />
    </commentGenerator>

    <!-- 数据库连接串配置 -->
    <jdbcConnection
    connectionURL="jdbc:oracle:thin:@ip:端口:chnldevn"
    driverClass="oracle.jdbc.driver.OracleDriver"
    password="userName" userId="password" />

    <!-- 类型转换器 -->
    <javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolver4MvneImpl">
    <!--
    true:使用BigDecimal对应DECIMAL和 NUMERIC数据类型
    false:默认,
    scale>0;length>18:使用BigDecimal;
    scale=0;length[10,18]:使用Long;
    scale=0;length[5,9]:使用Integer;
    scale=0;length<5:使用Short;
    -->
    <property name="forceBigDecimals" value="false"/>
    </javaTypeResolver>

    <!-- java实体类配置 -->
    <javaModelGenerator
    targetPackage="com.ai.channel.mgmt.dao.mapper.bo"
    targetProject="chan-srv-mgmt-core/src/main/java" />

    <!-- sqlMap映射xml配置 -->
    <sqlMapGenerator
    targetPackage="mybatis.mapper"
    targetProject="chan-srv-mgmt-core/src/main/resources" />
    <!-- mybatis接口类配置 -->
    <javaClientGenerator
    targetPackage="com.ai.channel.mgmt.dao.mapper.interfaces"
    targetProject="chan-srv-mgmt-core/src/main/java"
    type="XMLMAPPER" />

    <table tableName="MGMT_CHL_PHYSICAL" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>

    <table tableName="MGMT_CHL_PHYSICAL_HIS" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>

    <table tableName="MGMT_BAS_DECORATION_TEMPL" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>

    <table tableName="MGMT_CHL_DECORATION" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>
    <table tableName="MGMT_CHL_DECORATION_HIS" enableCountByExample="true"
    enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
    selectByExampleQueryId="true"/>

    </context>
    </generatorConfiguration>

    开启打怪升级之旅
  • 相关阅读:
    一个老博士的2015年终总结 (二)
    一个老博士的2015年终总结 (一) -- 偶然发现自己竟然在博客园发过帖子
    yolov3源码分析keras(二)损失函数计算
    yolov3源码分析keras(一)数据的处理
    [转载]HDMI on ZedBoard with Petalinux.
    基于zedBoard的手势识别及桌面操控系统_项目论文
    VGA显示SDRAM内容_1——DE1-SOC学习笔记(3)
    Avalon Slave外设简单实现——DE1-SOC学习笔记(2)
    Cyclone V 与 Avalon-MM资料整理——DE1-SOC学习笔记(1)
    ESP8266开发课堂之
  • 原文地址:https://www.cnblogs.com/zhangliwei/p/7821997.html
Copyright © 2011-2022 走看看