MyBatis处理动态设置表名

查询指定表中的数据

SQLMapper

dart 复制代码
    List<User> getUserByTableName(@Param("tableName") String tableName);

SQLMapper.xml

注意:这里不能用#{}

dart 复制代码
    <select id="getUserByTableName" resultType="User">
        select * from ${tableName}
    </select>

测试代码

相关推荐
Don.TIk2 分钟前
ChapterOne-搭建项目骨架
java·spring·spring cloud·mybatis
南极企鹅7 分钟前
事务&@Transactional注解
java·数据库·spring·oracle·mybatis
隐退山林6 小时前
JavaEE进阶:MyBatis 操作数据库(入门)
数据库·java-ee·mybatis
Devin~Y8 小时前
互联网大厂 Java 面试实录:JVM、Spring Boot、MyBatis、Redis、Kafka、Spring AI、K8s 全链路追问小Y
java·jvm·spring boot·redis·kafka·mybatis·spring security
码云骑士1 天前
MyBatis-Plus从入门到实战,Lambda查询+注解配置+SpringBoot整合全解析
mybatis
IronMurphy1 天前
Redis拷打第六讲
redis·spring·mybatis
那个失眠的夜1 天前
SpringBoot
java·开发语言·spring boot·spring·mvc·mybatis
接着奏乐接着舞1 天前
springboot mybatis
spring·tomcat·mybatis
Devin~Y1 天前
大厂Java面试实录:Spring Boot/Cloud、JVM、Redis、Kafka、MyBatis 到 RAG/Agent 的三轮连环问(含答案详解)
java·jvm·spring boot·redis·spring cloud·kafka·mybatis
Mr_pyx2 天前
面试题记录
jvm·数据结构·算法·spring·mybatis