Mybatis performance optimization: reducing database connections and mybatis Performance Optimization
The most important function for performance optimization is to reduce the interaction between databases. Many programmers generally only consider simple implementation functions during development, regardless of the Business complexity.
An important function of mybatis is to consider the techniques for joint queries:
<?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.cn.dao.TeacherMapper"> <resultMap type="com.cn.vo.Teacher" id="teacher"><id property="id" column="id" javaType="int" jdbcType="INTEGER" /><result property="name" column="name" javaType="string"jdbcType="VARCHAR" /><collection property="students" column="t_s_id" ofType="com.cn.vo.Student"><id property="sid" column="sid" javaType="int" jdbcType="INTEGER" /><result property="sname" column="sname" javaType="string"jdbcType="VARCHAR" /></collection></resultMap><select id="one2many" parameterType="int" resultMap="teacher">selectt.id,t.name,s.t_s_id,s.sid,s.snamefrom teacher t join student s on t.id= s.t_s_id where t.id = #{id} </select> </mapper>
collection
This application allows us to reduce the number of database connections at the service layer to achieve performance optimization.
Mybatis performance optimization to reduce database connection project demo download:
Http://download.csdn.net/detail/luozhonghua2014/8953781
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.