MyBatis performance optimization reduces database connectivity

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.