Mybatis-plus自定义Sql语句进行操作 使用Select注解
使用@Select注解来自定义方法。
·
使用注解方式来操作
package com.item.mybatis_plus.test.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.item.mybatis_plus.test.domain.Book;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
public interface UserDao extends BaseMapper<Book> {
@Select("select * from tbl_book where type=#{name}")
public List<Book> selectByName(String name);
}
使用@Select注解来自定义方法
@Select("select * from tbl_book where type=#{name}")
测试
更多推荐
已为社区贡献3条内容
所有评论(0)