mybatis性能优化之减少数据库连接
来源:互联网 发布:网络安全法手抄报内容 编辑:程序博客网 时间:2024/06/04 19:30
做性能优化的最重要的功能就是减少数据库的交互,很多程序员一般在开发的时候只考虑简单的实现功能,不管业务简单复杂,只要实现就行。
mybatis有个重要的功能就是考虑在联合查询时技巧:
<?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这个应用使我们在服务层减少数据库连接次数,从而达到优化性能的效果
mybatis性能优化之减少数据库连接工程demo下载:
http://download.csdn.net/detail/luozhonghua2014/8953781
0 0
- mybatis性能优化之减少数据库连接
- ASP.NET性能优化之减少请求
- ASP.NET性能优化之减少请求
- Android性能优化之减少过度绘制
- Web项目性能优化之减少HTTP请求次数优化
- Web项目性能优化之减少HTTP请求次数优化
- 性能优化之数据库连接池原理详解
- .net 性能优化之减少连接数据次数
- Unity优化之减少Drawcall
- 网站性能优化实践-cms性能优化之动态页面静态化、减少http请求和js压缩
- 前端性能优化-减少重绘
- 前端性能优化:重写自己,减少判断
- myBatis性能优化
- [Android 性能优化系列]布局篇之减少你的界面层级
- [Android 性能优化系列]布局篇之减少你的界面层级
- 【Unity3D游戏开发】性能优化之如何将包大小减少到极致(三六)
- 【U3D】后期渲染性能优化之---减少Draw Calls的调用
- Unity教程之-unity3d移动平台性能优化专题(三):减少面数
- 编译Openwrt固件
- Eclipse插件:Eclipse Color Theme
- CSS基础-25CSS常用操作-分类
- UE4信息交互-关卡蓝图内的交互
- POJ3243(Clever Y),POJ2417(Discrete Logging) && HDU2815(高次同余定律)
- mybatis性能优化之减少数据库连接
- Android安全机制介绍
- 【NOIP2013】花匠题解
- Hduoj1041【数学】
- leetcode 抢房子House Robber
- UVA10815 - Andy's First Dictionary
- POJ 2891 Strange Way to Express Integers
- codeforces 559C Gerald and Giant Chess(dp+组合数学)
- C语言编程入门——函数(下)