Commit b670cd8e authored by 刘凯's avatar 刘凯

1

parent b8ac6908
...@@ -15,387 +15,405 @@ ...@@ -15,387 +15,405 @@
limitations under the License. limitations under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.mybatis</groupId> <groupId>org.mybatis</groupId>
<artifactId>mybatis-parent</artifactId> <artifactId>mybatis-parent</artifactId>
<version>32-SNAPSHOT</version> <version>32-SNAPSHOT</version>
</parent> </parent>
<artifactId>mybatis</artifactId> <artifactId>mybatis</artifactId>
<version>3.3.0-SNAPSHOT</version> <version>3.3.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>mybatis</name> <name>mybatis</name>
<description> <description>
The MyBatis data mapper framework makes it easier to use a relational database with object-oriented The MyBatis data mapper framework makes it easier to use a relational database with object-oriented
applications. MyBatis couples objects with stored procedures or SQL statements using a XML descriptor or applications. MyBatis couples objects with stored procedures or SQL statements using a XML descriptor or
annotations. Simplicity is the biggest advantage of the MyBatis data mapper over object relational mapping annotations. Simplicity is the biggest advantage of the MyBatis data mapper over object relational mapping
tools. tools.
</description> </description>
<url>http://www.mybatis.org/core/</url> <url>http://www.mybatis.org/core/</url>
<contributors> <contributors>
<contributor> <contributor>
<name>Adam Gent</name> <name>Adam Gent</name>
<email>adam.gent@evocatus.com</email> <email>adam.gent@evocatus.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Andrea Selva</name> <name>Andrea Selva</name>
<email>selva.andre@gmail.com</email> <email>selva.andre@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Antonio Sánchez</name> <name>Antonio Sánchez</name>
<email>juntandolineas@gmail.com</email> <email>juntandolineas@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Arkadi Shishlov</name> <name>Arkadi Shishlov</name>
<email>arkadi.shishlov@gmail.com</email> <email>arkadi.shishlov@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Axel Doerfler</name> <name>Axel Doerfler</name>
<email>axel.doerfler@gmail.com</email> <email>axel.doerfler@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Chris Dadej</name> <name>Chris Dadej</name>
<email>chris.dadej@gmail.com</email> <email>chris.dadej@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Denis Vygovskiy</name> <name>Denis Vygovskiy</name>
<email>qizant@gmail.com</email> <email>qizant@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Franta Mejta</name> <name>Franta Mejta</name>
<email>mejta@rewor.cz</email> <email>mejta@rewor.cz</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Jurriaan Pruys</name> <name>Jurriaan Pruys</name>
<email>jurriaan@pruys.com</email> <email>jurriaan@pruys.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Keith Wong</name> <name>Keith Wong</name>
<email>wongkwl@gmail.com</email> <email>wongkwl@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Lasse Voss</name> <name>Lasse Voss</name>
<email>lasse.voss@motor-talk-gmbh.de</email> <email>lasse.voss@motor-talk-gmbh.de</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Luke Stevens</name> <name>Luke Stevens</name>
<email>nosuchluke@gmail.com</email> <email>nosuchluke@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Paul Krause</name> <name>Paul Krause</name>
<email>paulkrause88@alum.mit.edu</email> <email>paulkrause88@alum.mit.edu</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Peter Leibiger</name> <name>Peter Leibiger</name>
<email>kuhnroyal@gmail.com</email> <email>kuhnroyal@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Riccardo Cossu</name> <name>Riccardo Cossu</name>
<email>riccardo.cossu@gmail.com</email> <email>riccardo.cossu@gmail.com</email>
</contributor> </contributor>
<contributor> <contributor>
<name>Tomáš Neuberg</name> <name>Tomáš Neuberg</name>
<email>neuberg@m-atelier.cz</email> <email>neuberg@m-atelier.cz</email>
</contributor> </contributor>
</contributors> </contributors>
<scm> <scm>
<url>http://github.com/mybatis/mybatis-3</url> <url>http://github.com/mybatis/mybatis-3</url>
<connection>scm:git:ssh://github.com/mybatis/mybatis-3.git</connection> <connection>scm:git:ssh://github.com/mybatis/mybatis-3.git</connection>
<developerConnection>scm:git:git+ssh://git@github.com/mybatis/mybatis-3.git</developerConnection> <developerConnection>scm:git:git+ssh://git@github.com/mybatis/mybatis-3.git</developerConnection>
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>
<issueManagement> <issueManagement>
<system>GitHub Issue Management</system> <system>GitHub Issue Management</system>
<url>https://github.com/mybatis/mybatis-3/issues</url> <url>https://github.com/mybatis/mybatis-3/issues</url>
</issueManagement> </issueManagement>
<ciManagement> <ciManagement>
<system>Travis CI</system> <system>Travis CI</system>
<url>https://travis-ci.org/mybatis/mybatis-3/</url> <url>https://travis-ci.org/mybatis/mybatis-3/</url>
</ciManagement> </ciManagement>
<distributionManagement> <distributionManagement>
<site> <site>
<id>github</id> <id>github</id>
<url>gitsite:git@github.com/mybatis/mybatis-3.git</url> <url>gitsite:git@github.com/mybatis/mybatis-3.git</url>
</site> </site>
</distributionManagement> </distributionManagement>
<properties> <properties>
<clirr.comparisonVersion>3.2.7</clirr.comparisonVersion> <clirr.comparisonVersion>3.2.7</clirr.comparisonVersion>
<findbugs.onlyAnalyze>org.apache.ibatis.*</findbugs.onlyAnalyze> <findbugs.onlyAnalyze>org.apache.ibatis.*</findbugs.onlyAnalyze>
<osgi.export>org.apache.ibatis.*;version=${project.version};-noimport:=true</osgi.export> <osgi.export>org.apache.ibatis.*;version=${project.version};-noimport:=true</osgi.export>
<osgi.import>*;resolution:=optional</osgi.import> <osgi.import>*;resolution:=optional</osgi.import>
<osgi.dynamicImport>*</osgi.dynamicImport> <osgi.dynamicImport>*</osgi.dynamicImport>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>ognl</groupId> <groupId>ognl</groupId>
<artifactId>ognl</artifactId> <artifactId>ognl</artifactId>
<version>3.0.8</version> <version>3.0.8</version>
<scope>provided</scope> <scope>provided</scope>
<optional>true</optional> <optional>true</optional>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>javassist</groupId> <groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId> <artifactId>javassist</artifactId>
</exclusion> <version>3.18.2-GA</version>
</exclusions> <scope>provided</scope>
</dependency> <optional>true</optional>
<dependency> </dependency>
<groupId>org.javassist</groupId> <dependency>
<artifactId>javassist</artifactId> <groupId>org.slf4j</groupId>
<version>3.18.2-GA</version> <artifactId>slf4j-api</artifactId>
<scope>provided</scope> <version>1.7.7</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version> <version>1.7.7</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j</artifactId>
<version>1.7.7</version> <version>1.2.17</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<version>1.2.17</version> <version>2.1</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>commons-logging</groupId>
<artifactId>log4j-core</artifactId> <artifactId>commons-logging</artifactId>
<version>2.1</version> <version>1.2</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-logging</groupId> <groupId>cglib</groupId>
<artifactId>commons-logging</artifactId> <artifactId>cglib</artifactId>
<version>1.2</version> <version>3.1</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.1</version>
<optional>true</optional>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.11.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>transaction-api</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
<!-- postgresql driver is required to run the refcursor tests -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>derby.stream.error.file</name>
<value>target/derby.log</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>jarjar-maven-plugin</artifactId>
<version>1.9</version>
<configuration>
<input>{classes}</input>
<input>{test-classes}</input>
<includes>
<include>ognl:ognl</include>
<include>org.javassist:javassist</include>
</includes>
<rules>
<rule>
<pattern>ognl.**</pattern>
<result>org.apache.ibatis.ognl.@1</result>
</rule>
<rule>
<pattern>javassist.**</pattern>
<result>org.apache.ibatis.javassist.@1</result>
</rule>
<keep>
<pattern>org.apache.ibatis.**</pattern>
</keep>
</rules>
<overwrite>true</overwrite>
</configuration>
<executions>
<execution>
<id>jarjar-classes</id>
<phase>process-test-classes</phase>
<goals>
<goal>jarjar</goal>
</goals>
<configuration>
<input>{classes}</input>
</configuration>
</execution>
<execution>
<id>jarjar-test-classes</id>
<phase>process-test-classes</phase>
<goals>
<goal>jarjar</goal>
</goals>
<configuration>
<input>{test-classes}</input>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<locales>en,es,ja,fr,zh_CN,ko</locales>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<instrumentation>
<ignores>
<ignore>org.apache.ibatis.ognl.*</ignore>
<ignore>org.apache.ibatis.javassist.*</ignore>
</ignores>
<excludes>
<exclude>org/apache/ibatis/ognl/**/*.class</exclude>
<exclude>org/apache/ibatis/javassist/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources> <!-- Test dependencies -->
<resource> <dependency>
<directory>${project.basedir}</directory> <groupId>junit</groupId>
<targetPath>META-INF</targetPath> <artifactId>junit</artifactId>
<includes> <version>4.11</version>
<include>LICENSE</include> <scope>test</scope>
<include>NOTICE</include> </dependency>
</includes> <dependency>
</resource> <groupId>org.hsqldb</groupId>
<resource> <artifactId>hsqldb</artifactId>
<directory>${project.build.sourceDirectory}</directory> <version>2.3.2</version>
<excludes> <scope>test</scope>
<exclude>**/*.java</exclude> </dependency>
</excludes> <dependency>
</resource> <groupId>mysql</groupId>
</resources> <artifactId>mysql-connector-java</artifactId>
<testResources> <version>6.0.6</version>
<testResource> </dependency>
<directory>${project.build.testSourceDirectory}</directory> <dependency>
<excludes> <groupId>org.apache.derby</groupId>
<exclude>**/*.java</exclude> <artifactId>derby</artifactId>
</excludes> <version>10.11.1.1</version>
</testResource> <scope>test</scope>
</testResources> </dependency>
<pluginManagement> <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.21.0-GA</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>transaction-api</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>3.2</version>
</dependency>
<!-- postgresql driver is required to run the refcursor tests -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins> <plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin> <plugin>
<groupId>org.eclipse.m2e</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>lifecycle-mapping</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>1.0.0</version> <configuration>
<systemProperties>
<property>
<name>derby.stream.error.file</name>
<value>target/derby.log</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>jarjar-maven-plugin</artifactId>
<version>1.9</version>
<configuration> <configuration>
<lifecycleMappingMetadata> <input>{classes}</input>
<pluginExecutions> <input>{test-classes}</input>
<pluginExecution> <includes>
<pluginExecutionFilter> <include>ognl:ognl</include>
<groupId>org.sonatype.plugins</groupId> <include>org.javassist:javassist</include>
<artifactId>jarjar-maven-plugin</artifactId> </includes>
<versionRange>[1.9,)</versionRange> <rules>
<goals> <rule>
<goal>jarjar</goal> <pattern>ognl.**</pattern>
</goals> <result>org.apache.ibatis.ognl.@1</result>
</pluginExecutionFilter> </rule>
<action> <rule>
<ignore></ignore> <pattern>javassist.**</pattern>
</action> <result>org.apache.ibatis.javassist.@1</result>
</pluginExecution> </rule>
</pluginExecutions> <keep>
</lifecycleMappingMetadata> <pattern>org.apache.ibatis.**</pattern>
</keep>
</rules>
<overwrite>true</overwrite>
</configuration> </configuration>
<executions>
<execution>
<id>jarjar-classes</id>
<phase>process-test-classes</phase>
<goals>
<goal>jarjar</goal>
</goals>
<configuration>
<input>{classes}</input>
</configuration>
</execution>
<execution>
<id>jarjar-test-classes</id>
<phase>process-test-classes</phase>
<goals>
<goal>jarjar</goal>
</goals>
<configuration>
<input>{test-classes}</input>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<locales>en,es,ja,fr,zh_CN,ko</locales>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<instrumentation>
<ignores>
<ignore>org.apache.ibatis.ognl.*</ignore>
<ignore>org.apache.ibatis.javassist.*</ignore>
</ignores>
<excludes>
<exclude>org/apache/ibatis/ognl/**/*.class</exclude>
<exclude>org/apache/ibatis/javassist/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement>
</build> <resources>
<resource>
<directory>${project.basedir}</directory>
<targetPath>META-INF</targetPath>
<includes>
<include>LICENSE</include>
<include>NOTICE</include>
</includes>
</resource>
<resource>
<directory>${project.build.sourceDirectory}</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>${project.build.testSourceDirectory}</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.sonatype.plugins</groupId>
<artifactId>jarjar-maven-plugin</artifactId>
<versionRange>[1.9,)</versionRange>
<goals>
<goal>jarjar</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project> </project>
package com.liukai.demo;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.IOException;
import java.io.InputStream;
/**
* @author liukai
* @Description: TODO
* @date 2020/2/254:41 下午
*/
public class Main {
public static void main(String[] args) {
String resource="mybatis-config.xml";
InputStream inputStream=null;
try {
inputStream = Resources.getResourceAsStream(resource);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SqlSessionFactory sqlSessionFactory=null;
sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
SqlSession sqlSession=null;
try {
sqlSession=sqlSessionFactory.openSession();
RoleMapper roleMapper=sqlSession.getMapper(RoleMapper.class);
Role role=roleMapper.getRole(1L);
System.out.println(role.getId()+":"+role.getRoleName()+":"+role.getNote());
sqlSession.commit();
} catch (Exception e) {
// TODO Auto-generated catch block
sqlSession.rollback();
e.printStackTrace();
}finally {
sqlSession.close();
}
}
}
package com.liukai.demo;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import org.apache.ibatis.type.TypeHandler;
import org.apache.log4j.Logger;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* @author liukai
* @Description: TODO
* @date 2020/2/254:41 下午
*/
@MappedTypes({String.class})
@MappedJdbcTypes(JdbcType.VARCHAR)
public class MyStringHandler implements TypeHandler<String> {
private Logger log=Logger.getLogger(MyStringHandler.class);
@Override
public String getResult(ResultSet rs, String colName) throws SQLException {
log.info("使用我的TypeHandler,ResultSet列名获取字符串");
return rs.getString(colName);
}
@Override
public String getResult(ResultSet rs, int index) throws SQLException {
log.info("使用我的TypeHandler,ResultSet下标获取字符串");
return rs.getString(index);
}
@Override
public String getResult(CallableStatement cs, int index) throws SQLException {
log.info("使用我的TypeHandler,CallableStatement下标获取字符串");
return cs.getString(index);
}
@Override
public void setParameter(PreparedStatement ps, int index, String value, JdbcType arg3) throws SQLException {
log.info("使用我的TypeHandler");
ps.setString(index, value);
}
}
package com.liukai.demo;
/**
* @author liukai
* @Description: TODO
* @date 2020/2/254:44 下午
*/
public class Role {
private long id;
private String roleName;
private String note;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
}
package com.liukai.demo;
/*
* @author gethin
*/
public interface RoleMapper {
public Role getRole(Long id);
public Role findRole(String roleName);
public int deleteRole(Long id);
public int insertRole(Role role);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liukai.demo.RoleMapper">
<resultMap type="role" id="roleMap">
<id column="id" property="id" javaType="long" jdbcType="BIGINT" />
<result column="role_name" property="roleName" javaType="string"
jdbcType="VARCHAR" />
<result column="note" property="note"
typeHandler="com.liukai.demo.MyStringHandler" />
</resultMap>
<select id="getRole" parameterType="long" resultMap="roleMap">
select
id,role_name as roleName,note from role where id=#{id}
</select>
<select id="findRole" parameterType="long" resultMap="roleMap">
select
id,role_name,note from role where role_name like CONCAT('%',#{roleName
javaType=string,
jdbcType=VARCHAR,typeHandler=com.liukai.demo.MyStringHandler},'%')
</select>
<insert id="insertRole" parameterType="role">
insert into
role(role_name,note) value(#{roleName},#{note})
</insert>
<delete id="deleteRole" parameterType="long">
delete from role where
id=#{id}
</delete>
</mapper>
\ No newline at end of file
log4j.rootLogger=DEBUG,stdout
log4j.logger.org.mybatis=DUBUG
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.logDailyFile.layout.ConversionPattern = %5p %d %C:%m%n
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!--<settings>
&lt;!&ndash; <setting name="lazyLoadingEnabled" value="true"/>&ndash;&gt;
&lt;!&ndash; <setting name="aggressiveLazyLoading" value="false"/> &ndash;&gt;
</settings>-->
<typeAliases>
<typeAlias alias="role" type="com.liukai.demo.Role"/>
</typeAliases>
<typeHandlers>
<typeHandler jdbcType="VARCHAR" javaType="string" handler="com.liukai.demo.MyStringHandler"/>
</typeHandlers>
<!-- 定义数据库的信息,默认使用development数据库构建环境 -->
<environments default="development">
<environment id="development">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://dev.config.duibar.com:3306/test" />
<property name="username" value="dev" />
<property name="password" value="dev_fas015" />
</dataSource>
</environment>
</environments>
<!-- 定义映射器 -->
<mappers>
<package name="com.liukai.demo"/>
</mappers>
</configuration>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment