一、排序错误代码:example.orderBy(BaseEntity.Field.GMTUpdate + " desc");正确方式:一是:通过注解 @OrderBy(value = "DESC")二是:example.setOrderByClause("GMT_UPDATE DESC");注意此处是列名称,不是属性名。
二、处理oracle的null异常
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE configurationPUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration><settings><setting name="cacheEnabled" value="false"/><!--解决插入null的时候报错问题--><setting name="jdbcTypeForNull" value="NULL"/></settings></configuration>
三、
mapper的selectOne返回值可能是null,获取的结果应做null判定。
四public interface SequenceMapper{@Select("select SEQ_${tableName}.nextval from dual")int getSequence(@Param("tableName") String tableName);}
相关文章
- 浅谈使用PageHelper-Mybatis通用分页插件
- mybatis mapper.xml入参
- 多个mapper location时, mybatis spring的自动扫描配置
- Mybatis源码分析之Mapper执行SQL过程(三)
- 解决JRebel对myBatis Mapper 失效的问题
- Mybatis的Example常用函数和Mapper常用接口
- SpringBoot结合Mybatis 使用 mapper*.xml 进行数据库增删改查操作
- 【MyBatis学习18】使用注解配置Mapper
- mybatis中mapper的用法以及一些注意事项
- 关于Mybatis的@Param注解 及 mybatis Mapper中各种传递参数的方法