zoukankan      html  css  js  c++  java
  • Spring Boot MyBatis 使用注解动态表名查询

    代码如下:

    package com.peraglobal.mapper;

    import org.apache.ibatis.annotations.Delete;
    import org.apache.ibatis.annotations.Insert;
    import org.apache.ibatis.annotations.Mapper;
    import org.apache.ibatis.annotations.Param;
    import org.apache.ibatis.annotations.Select;

    @Mapper
    public interface UcenterUserMapper {

      @Select("select * from ${tableName}")
         public List<User> selectAll(@Param(value = "tableName") String tableName);

    }

    service 层调用,如下:

    package com.peraglobal.service;

    import java.util.List;

    import org.springframework.beans.factory.annotation.Autowired;

    import org.springframework.stereotype.Service;

    import com.peraglobal.mapper.UserMapper;
    import com.peraglobal.model.User;

    @Service
    public class UcenterUserService {

      @Autowired
           private UserMapper userMapper;

      public List<User> selectAll() {
               return ucenterUserMapper.selectAll("user");
         }

    }

    user 是需要传递的动态表名

  • 相关阅读:
    java中compareTo()用法详解
    random详解
    http协议介绍
    各种Web渗透测试平台
    提升黑客技能的十大网站
    .htaccess文件得用途
    XSS平台搭建
    session攻击(会话劫持+固定)与防御
    伪静态的原理以及应用
    Nessus激活码获取
  • 原文地址:https://www.cnblogs.com/zhyp/p/12924519.html
Copyright © 2011-2022 走看看