The most important function of performance optimization is to reduce the interaction of the database. Very many program apes generally only consider simple implementation functions when they are being developed, no matter how simple and complex the business is, just implement it.
One important function of MyBatis is to consider the technique of combining 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>
This application allows us to reduce the number of database connections at the service level. To achieve optimal performance
MyBatis performance Optimization Reduced database connection Projectdemo Download:
http://download.csdn.net/detail/luozhonghua2014/8953781
MyBatis performance optimization reduces database connectivity