Mybatis performance optimization: reducing database connections and mybatis Performance Optimization

Source: Internet
Author: User

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.

Related Article

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.