This page lists scripts for testing the different parts of the MyBatis Generator UI. This information may also be helpful in learning how to use the different parts of the Eclipse user interface for MyBatis Generator.
root
is also root
drop schema if exists mbgtest; create schema mbgtest; use mbgtest; create table a (id int not null, description varchar(50), primary key(id)); create table b (id int not null, description varchar(50), primary key(id)); create table c (id int not null, description varchar(50), primary key(id)); create table d (id int not null, description varchar(50), primary key(id)); create table e (id int not null, description varchar(50), primary key(id)); create table f (id int not null, description varchar(50), primary key(id)); create table g (id int not null, description varchar(50), primary key(id)); create table h (id int not null, description varchar(50), primary key(id)); create table i (id int not null, description varchar(50), primary key(id)); create table j (id int not null, description varchar(50), primary key(id));
The following tests are intended to be executed in the order listed. Some tests build on items created in previous tests.
src
generatedsrc
src
folder called config
config
package<?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="/JavaTools/mysql-connector-java-5.1.17/mysql-connector-java-5.1.17-bin.jar" /> <context id="context1" targetRuntime="MyBatis3" > <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/mbgtest" userId="root" password="root" > </jdbcConnection> <javaModelGenerator targetPackage="gen.model" targetProject="MBGTest" /> <sqlMapGenerator targetPackage="gen.mapper" targetProject="MBGTest" /> <javaClientGenerator targetPackage="gen.mapper" targetProject="MBGTest" type="XMLMAPPER" /> <table tableName="a" /> </context> <context id="context2" targetRuntime="MyBatis3" > <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/mbgtest" userId="root" password="root" > </jdbcConnection> <javaModelGenerator targetPackage="gen.src.model" targetProject="MBGTest/generatedsrc" /> <sqlMapGenerator targetPackage="gen.src.mapper" targetProject="MBGTest/generatedsrc" /> <javaClientGenerator targetPackage="gen.src.mapper" targetProject="MBGTest/generatedsrc" type="XMLMAPPER" /> <table schema="mbgtest" tableName="%" /> </context> </generatorConfiguration>
<classPathEntry>
element
if different on your systemgen.model.A.java
in the "src" folder@mbggenerated
commentsmergetest
and generate a getter and setter
for the field.gen.model.A.java
in the "src" foldermergetest
, and its getter and setter remain
in the file (they will have been moved to the bottom of the file)context1
to SPRING
src.dao.ADAOImpl
now extends SqlMapClientDaoSupport
.
Note that there will be several errors in the workspace now because of the new dependencies
on Spring that were generated.context1
back to GENERIC-CI
src.dao.ADAOImpl
doesn't extend anything. There will be one
error in the file related to the Spring import (the Java merger does not reconcile all
imports). Delete the import and verify that there are no other errors in the
workspace. Also, verify that the field mergetest
and its
associated getter and setter still exist.<classPathEntry>
element from the file.build.xml
in the "MBGTest/src/config" package.<project default="runMyBatisGenerator"> <target name="runMyBatisGenerator"> <eclipse.convertPath resourcepath="MBGTest/src/config/generatorConfig.xml" property="thePath"/> <mybatis.generate configfile="${thePath}" > </mybatis.generate> </target> </project>
gen.dao.ADAO.java
. There will now be errors in the
workspace.build.xml
file, then select the
menu option "Run As>Ant Build...". You should see the Ant launch configuration
dialog open.build.xml
file, then select the
menu option "Run As>Ant Build...". You should see the Ant launch configuration
dialog open.