Mybatis-plus自定义Sql语句进行操作 使用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}")

测试
在这里插入图片描述

在这里插入图片描述


版权声明:本文为qq_45007567原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。