使用注解方式来操作

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}")

测试
在这里插入图片描述

在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐