Advertisement

MyBatis-Plus 基础 自定义 SQL 操作 (四)

阅读量:

在运用自定义SQL语句的过程中,若希望同时调用Wrapper功能,则所采用的mybatis-plus版本必须不低于3.0.7,此为重要注意事项!!!!

注解方式解析

1,映射器接口

复制代码
 /** * 获取自定义SQL 简化自定义XML复杂情况
    
  * <p>使用方法</p>
    
  * <p>`自定义sql` + ${ew.customSqlSegment}</p>
    
  * <p>1.逻辑删除需要自己拼接条件 (之前自定义也同样)</p>
    
  * <p>2.不支持wrapper中附带实体的情况 (wrapper自带实体会更麻烦)</p>
    
  * <p>3.用法 ${ew.customSqlSegment} (不需要where标签包裹,切记!)</p>
    
  * <p>4.ew是wrapper定义别名,可自行替换</p>
    
  */
    
 public interface UserMapper extends BaseMapper<User> {
    
 //	自定义SQL:按输入条件查询数据库中数据
    
 	@Select("select * from user ${ew.customSqlSegment}")
    
 	List<User> selectUsers(@Param(C

全部评论 (0)

还没有任何评论哟~