首页 > 其他分享 >mybatis

mybatis

时间:2022-10-13 23:44:57浏览次数:55  
标签:缓存 一级 二级缓存 添加 mybatis 序列化

目录

一级缓存和二级缓存

  • 一级缓存自带的,有效范围:SqlSession
  • 二级缓存需要配置,4个点:
    1.conf全局配置文件

<setting name="cacheEnabled" value="true">

2.mapper-xml添加

<cache eviction="FIFO" flushInterval="6000" size="512" readOnly="true"/>

3.查询方法添加属性:

<select id="" resultType="User" useCache="true">

4.pojo对象需要实现序列化接口

标签:缓存,一级,二级缓存,添加,mybatis,序列化
From: https://www.cnblogs.com/jf666/p/16790099.html

相关文章

  • Mybatis-plus分页查询和条件查询通用写法- 动态接口参数
    一查询条件VO/***@className:TeacherQueryVo*@description:讲师查询条件封装*@date:2020/11/18*@author:cakin*/@ApiModel("Teacher查询对象")@Datapubl......
  • mybatis-plus批量插入性能提升
    最近在引入mybatis-plus后发现其批量插入的性能不高,所以与mybatis的<foreach/>标签生成的sql插入性能做了对比测试环境:6核12线程,16g内存本地数据库,没有网络传输数据库......
  • spring中@Param和mybatis中@Param使用区别(暂时还没接触)
    1、spring中@Param(org.springframework.data.repository.query.Param)intselectRoleCount(@Param("businessId")IntegerbusinessId,@Param("memberId")Long2、mybatis......
  • Mybatis---动态查询(choose,when,otherwise)
    choose(when,otherwise)标签有时候我们并不想应用所有的条件,而只是想从多个选项中选择一个。而使用if标签时,只要test中的表达式为true,就会执行if标签中的条件。MyBat......
  • Mybatis传递多个参数的几种方式
    1、顺序传参法publicUserselectUser(Stringname,intdeptId);<selectid="selectUser"resultMap="UserResultMap">select*fromuserwhereuser_name......
  • MyBatis中三种分页查询方式
    文章目录通过limit分页查询通过Rowbounds通过分页插件pagehelper通过limit分页查询mapper接口1List<User>getUserByLimit(Map<String,Integer>map);mapper.xm......
  • Mybatis传参的方式总结
    mybatis传参的几种方式?目录第一种情形,传入单个参数userId第二种情况,传入多个参数userId,sex使用索引对应值第三种情形,传入多个参数userId,sex使用注解@Param第四......
  • SpringBoot+MyBatis Plus对Map中Date格式转换的处理
    在SpringBoot项目中,如何统一JSON格式化中的日期格式问题现在的关系型数据库例如PostgreSQL/MySQL,都已经对JSON类型提供相当丰富的功能,项目中对于不需要检索但是......
  • MyBatisPlus笔记
    MyBatisPlus快速入门1.创建数据库mybatisplus2.创建user表并插入数据DROPTABLEIFEXISTSuser;CREATETABLEuser(idBIGINT(20)NOTNULLCOMMENT'主键I......
  • mybatis返回值乱码(mysql数据库编码正确)
    解决办法:在springmvc.xml文件里面插入<!--解决乱码问题--><mvc:annotation-driven><mvc:message-converters><beanclass="org.springfram......