mybatis的基本使用
来源:互联网 发布:江南大学网络接入系统 编辑:程序博客网 时间:2024/06/05 07:14
1.mybatis支持声明式数据缓存,当一条SQL语句被标记为可缓存之后,先从数据库中查找,所有的数据都存到高速缓存中,默认情况下是基于Java的hashMap实现
2.在同一个xml中ID唯一,namespace这个名称空间要配置对应的Mapper,
<settings><setting name="mapUnderscoreToCamelCase" value = "true"></setting>
</settings>
3.对于resultMap用法,
<resultMap type="com.ld.model.operations.vo.FaultShowDetailVo" 类名
id="showDetail" 唯一标识
autoMapping="true" 自动匹配没写出来的字段(名字一样且最少有一个这个类中的属性)
extends="" > 继承父resultMap的Id
<id column="faultId" property="faultId" javaType="string"/> id唯一标识对象
<collection property="faultImgs" javaType="java.util.ArrayList" 集合映射
ofType="com.ld.model.operations.vo.FaultImgVo">
<result column="fileName" property="fileName" javaType="String" /> 其他字段
<result column="imgType" property="imgType" javaType="String" />
</collection>
<association property="" 关联对象
fetchType="lazy" 懒加载
columnPrefix="" 列名前缀
foreignColumn="" 外键
resultMap="" 对应map
column="" autoMapping="true" javaType=""></association>
<constructor> 配置使用构造方法注入结果
<idArg column="" name="" /> 唯一标识和与resultMap中的Id,一样
<arg column="" name="" />与resultMap中的result,一样
</constructor>
</resultMap>
4.insert的使用
<insert id="" flushCache="true" 设置为true清空一级二级缓存
timeout=""设置在抛出异常之前,驱动程序等待数据返回请求的秒数
statementType="STATEMENT" 对应的STATEMENT,PREPARED,CALLABLE,mybatis分别对应statement,preparement,CallableStatement ,默认为PREPARED
useGeneratedKeys="true" 默认为false,如果设置为true,mybatis会使用JDBC的getGenerateKeys方法取出数据库内部生产到的主键
keyProperty=""
keyColumn="" >
<selectKey keyColumn="" keyProperty="" order="AFTER">
SELECT LAST_INSERT_ID() 在MySQL中的主键生产策略
SELECT SEQ_ID.nextval from dual 在Oracle中的主键生产策略 Order=“BEFORE”
</selectKey>
</insert>
- MyBatis的基本使用
- Mybatis的基本使用
- mybatis的基本使用
- MyBatis的基本使用
- mybatis的基本使用
- mybatis的基本使用
- mybatis的基本使用
- MyBatis框架的基本使用
- Mybatis的基本使用实例
- mybatis的基本使用及配置
- Mybatis的基本配置和使用
- MyBatis基本使用步骤
- MyBatis基本使用
- mybatis-mybatis的基本配置
- MyBatis的基本配置
- Mybatis的基本使用方法
- Maven下的Mybatis基本配置和使用
- 一、MyBatis框架的配置与基本使用
- vue的v_if
- Codeforces 892 D. Gluttony (思维)
- print、print_r、echo var_dump的区别
- 一. TabLayout 横滑布局文件xml
- webView加载Https网页
- mybatis的基本使用
- 本地计算机的oracleoradb11g_home1tnslistener服务启动后停止,某些服务在未由其他服务或程序使用时将自动停止
- 数据库视频总结
- MapReduce之如何处理失败的task
- Linux常用命令集
- 将数组A中的内容和数组B中的内容进行交换。(数组一样大)
- nw.js学习
- 回溯--深度优先搜索(数字n的组合数)
- ssm框架-简单的分页查询