mybatis_plus入门笔记

Mybatis-Plus条件构造器 Mybatis-Plus条件构造器 1、allEq:全部 2、eq:等于 3、ne:不等于 4、gt:大于 5、ge:大于等于 6、lt:小于 阅读详情

用到的数据库信息
	#创建用户表
	CREATE TABLE user (
	    id BIGINT(20) PRIMARY KEY NOT NULL COMMENT '主键',
	    name VARCHAR(30) DEFAULT NULL COMMENT '姓名',
	    age INT(11) DEFAULT NULL COMMENT '年龄',
	    email VARCHAR(50) DEFAULT NULL COMMENT '邮箱',
	    manager_id BIGINT(20) DEFAULT NULL COMMENT '直属上级id',
	    create_time DATETIME DEFAULT NULL COMMENT '创建时间',
	    CONSTRAINT manager_fk FOREIGN KEY (manager_id)
	        REFERENCES user (id)
	)  ENGINE=INNODB CHARSET=UTF8;
	
	#初始化数据:
	INSERT INTO user (id, name, age, email, manager_id
	    , create_time)
	VALUES (1087982257332887553, '大boss', 40, 'boss@baomidou.com', NULL
	        , '2019-01-11 14:20:20'),
	    (1088248166370832385, '王天风', 25, 'wtf@baomidou.com', 1087982257332887553
	        , '2019-02-05 11:12:22'),
	    (1088250446457389058, '李艺伟', 28, 'lyw@baomidou.com', 1088248166370832385
	        , '2019-02-14 08:31:16'),
	    (1094590409767661570, '张雨琪', 31, 'zjq@baomidou.com', 1088248166370832385
	        , '2019-01-14 09:15:15'),
	    (1094592041087729666, '刘红雨', 32, 'lhm@baomidou.com', 1088248166370832385
	        , '2019-01-14 09:48:16');
依赖
	<dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>starter-latest-version</version>
    </dependency>
springboot配置文件
		spring:
		  datasource:
		    driver-class-name: com.mysql.cj.jdbc.Driver
		    username: root
		    password: root
		    url: jdbc:mysql://localhost:3306/test?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
		logging:
		  level:
		    root: warn
		    org.ywb.demo.dao: trace
		  pattern:
		    console: '%p%m%n'
配置MapperScan注解
	@SpringBootApplication
	@MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper")
	public class Application {
	
	    public static void main(String[] args) {
	        SpringApplication.run(QuickStartApplication.class, args);
	    }
	}
常用注解
  1. @TableName:对数据表名注解
  2. @TableId:表主键标识
  3. @TableId(value = “id”, type = IdType.AUTO):自增;
  4. @TableField:表字段标识
  5. @TableLogic:表字段逻辑处理注解(逻辑删除)
  6. @TableField(condition = SqlCondition.LIKE):表示该属性可以模糊搜索。
   	@Data
   	@TableName("t_user")
   	public class User {
   	    @TableId("user_id")
   	    private Long id;
   	    @TableField("real_name")
   	    private String name;
   	    private Integer age;
   	    private String email;
   	    private Long managerId;
   	    private LocalDateTime createTime;
   	}

CRUD

1.创建实体类
	@Data
	public class User {
	    private Long id;
	    private String name;
	    private Integer age;
	    private String email;
	    private String managerId;
	    private LocalDateTime createTime;
	}
2.在dao包中创建mapper接口,并继承BaseMapper
	@Repository
	@Mapper
	public interface UserDao extends BaseMapper<User> {
		List<User> selectAll(@Param(Constants.WRAPPER) Wrapper<User> wrapper);
	
	    IPage<User> selectUserPage(Page<User> page, @Param(Constants.WRAPPER) Wrapper<User> wrapper);
	}
3.普通查询
	@Test
	    public void selectByMap() {
	        Map<String, Object> map = new HashMap<>();
	        map.put("name", "王天风");
	        map.put("manager_id", 1087982257332887553L);
	        //where name = 王天风 and manager_id = 1087982257332887553
	        List<User> users = userMapper.selectByMap(map);
	        users.forEach(System.out::println);
	    }
4.条件构造器查询
1.模糊查询
	/**
	     * 查询名字中包含'雨'并且年龄小于40
	     * where name like '%雨%' and age < 40
	     */
	    @Test
	    public void selectByWrapper(){
	        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
	        queryWrapper.like("name","雨").lt("age",40);
	        List<User> userList = userMapper.selectList(queryWrapper);
	        userList.forEach(System.out::println);
	    }
	
2.嵌套查询
	/**
	     * 创建日期为2019年2月14日并且直属上级姓名为王姓
	     * date_format(create_time,'%Y-%m-%d') and manager_id in (select id from user where name like '王%')
	     */
	    @Test
	    public void selectByWrapper2(){
	        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
	        queryWrapper.apply("date_format(create_time,'%Y-%m-%d')={0}","2019-02-14")
	                .inSql("manager_id","select id from user where name like '王%'");
	        List<User> userList = userMapper.selectList(queryWrapper);
	        userList.forEach(System.out::println);
	    }

注:日期使用占位符形式进行查询,防止SQL注入

3.and&or
	/**
	     * 名字为王姓,(年龄小于40或者邮箱不为空)
	     */
	    @Test
	    public void selectByWrapper3(){
	        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
	        queryWrapper.likeRight("name","王").and(wq-> wq.lt("age",40).or().isNotNull("email"));
	
	        List<User> userList = userMapper.selectList(queryWrapper);
	        userList.forEach(System.out::println);
	
	    }

4.between & and
	/**
	     * 名字为王姓,(年龄小于40,并且年龄大于20,并且邮箱不为空)
	     */
	    @Test
	    public void selectWrapper4(){
	        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
	        queryWrapper.likeRight("name", "王").and(wq -> wq.between("age", 20, 40).and(wqq -> wqq.isNotNull("email")));
	        List<User> userList = userMapper.selectList(queryWrapper);
	        userList.forEach(System.out::println);
	    }
5.nested
	/**
	     * (年龄小于40或者邮箱不为空)并且名字为王姓
	     * (age<40 or email is not null)and name like '王%'
	     */
	    @Test
	    public void selectWrapper5(){
	        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
	
	        queryWrapper.nested(wq->wq.lt("age",40).or().isNotNull("email")).likeRight("name","王");
	
	        List<User> userList = userMapper.selectList(queryWrapper);
	        userList.forEach(System.out::println);
	    }
6.in
	/**
	     * 年龄为30,31,35,34的员工
	     */
	    @Test
	    public void selectWrapper6(){
	        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
	
	        queryWrapper.in("age", Arrays.asList(30,31,34,35));
	
	        List<User> userList = userMapper.selectList(queryWrapper);
	        userList.forEach(System.out::println);
	    }
condition的作用
	@Test
	    public void testCondition() {
		    String name = "大";
		    String email = "";
		    condition(name, email);
	    }
	
	
	    public void condition(String name, String email) {
	        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
	        /*if (StringUtils.isNotEmpty(name)) {
	            queryWrapper.like("name", name);
	        }
	        if (StringUtils.isNotEmpty(email)) {
	            queryWrapper.like("email", email);
	        }*/
	        queryWrapper.like(StringUtils.isNotEmpty(name),"name", name)
	                .like(StringUtils.isNotEmpty(email), "email", email);
	        List<User> users = userMapper.selectList(queryWrapper);
	        users.forEach(System.out::println);
	    }

这个condition的作用是为true时,执行其中的SQL条件,为false时,忽略设置的SQL条件。

实体作为条件构造方法的参数
	@Test
	    public void selectByWrapperEntity() {
		    //WHERE name='王天风' AND age=30 AND name LIKE '%王%' AND age < 40
	        User whereUser = new User();
		    whereUser.setName("王天风");
	        whereUser.setAge(30);
	        QueryWrapper<User> queryWrapper = new QueryWrapper<>(whereUser);
	        queryWrapper.like("name", "王").lt("age", 40);
	        List<User> users = userMapper.selectList(queryWrapper);
	        users.forEach(System.out::println);
	    }
Lambda条件构造器
	@Test
	    public void selectLambda() {
		    //优点:防止属性写错
		    //WHERE name LIKE ? AND age < ?
	        LambdaQueryWrapper<User> lambda = new QueryWrapper<User>().lambda();
	        //LambdaQueryWrapper<User> lambda2 = new LambdaQueryWrapper<>();
	        //LambdaQueryWrapper<User> lambda3 = Wrappers.<User>lambdaQuery();
	        lambda.like(User::getName, "王").lt(User::getAge, 40);
	        List<User> users = userMapper.selectList(lambda);
	        users.forEach(System.out::println);
	    }
	
	    @Test
	    public void selectLambda2() {
		    //WHERE name LIKE ? AND age >= ?
	        List<User> users = new LambdaQueryChainWrapper<User>(userMapper)
	                .like(User::getName, "王").ge(User::getAge, 30).list();
	        users.forEach(System.out::println);
	    }
自定义SQL
  1. 在resources资源文件夹下新建mapper文件夹,并将mapper文件夹的路径配置到配置文件中
  2. 在mapper 文件夹中新建UserMapper.xml。
  3. 像mybatis那样在UseMapper接口中写接口,在UserMapper接口中写SQL即可。
UserMapper
		@Mapper
		@Repository
		public interface UserMapper extends BaseMapper<User> {
		    @Select("select * from user ${ew.customSqlSegment}")
		    List<User> selectAll(@Param(Constants.WRAPPER) Wrapper<User> wrapper);
		}
UserMapper.xml
	<?xml version="1.0" encoding="UTF-8" ?>
	<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
	<mapper namespace="org.ywb.demo.dao.UserMapper">
	
	    <select id="selectAll" resultType="org.ywb.demo.pojo.User">
	        select * from user
	    </select>
	</mapper>
分页查询
  1. 新建config类,在config类中创建 PaginationInterceptor 对象
		 @Configuration
		public class MybatisPlusConfig {
		
	    @Bean
	    public PaginationInterceptor paginationInterceptor(){
	        return new PaginationInterceptor();
	    }
	}
  1. 测试
		/**
	     * 查询年龄大于20 的用户信息,并以每页容量为两条分页的形式返回。
	     */
			 @Test
			    public void selectPage(){
			        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
			        queryWrapper.ge("age",20);
	
	        //设置当前页和页容量
	        Page<User> page = new Page<>(1, 2);
	
	        IPage<User> userIPage = userMapper.selectPage(page, queryWrapper);
	
	        System.out.println("总页数:"+userIPage.getPages());
	        System.out.println("总记录数:"+userIPage.getTotal());
	        userIPage.getRecords().forEach(System.out::println);
	    }
更新
	@Test
	    public void updateById() {
	        //UPDATE user SET age=?, email=? WHERE id=?
	        User user = new User();
	        user.setId(1087982257332887553L);
	        user.setAge(41);
	        user.setEmail("daboss@baomidou.com");
	        int rows = userMapper.updateById(user);
	        System.out.println("影响记录数:" + rows);
	    }
	
	    @Test
	    public void updateByWrapper() {
	        //UPDATE user SET email=? WHERE name = ? AND age = ?
	        UpdateWrapper<User> userUpdateWrapper = new UpdateWrapper<>();
	        userUpdateWrapper.eq("name", "王天风").eq("age", 41);
	        User user = new User();
	        user.setEmail("boss@qq.com");
	        int update = userMapper.update(user, userUpdateWrapper);
	        System.out.println("影响记录数:" + update);
	    }
	
	    @Test
	    public void updateByWrapper1() {
	        //UPDATE user SET email=? WHERE name LIKE CONCAT('%',?,'%')
	        //like是因为在实体类name属性上使用了注解@TableField(condition = SqlCondition.LIKE)
	        User whereUser = new User();
	        whereUser.setName("王天风");
	        UpdateWrapper<User> userUpdateWrapper = new UpdateWrapper<>(whereUser);
	        User user = new User();
	        user.setEmail("boss@qq.com");
	        int update = userMapper.update(user, userUpdateWrapper);
	        System.out.println("影响记录数:" + update);
	    }
	
	    @Test
	    public void updateByWrapper2() {
	        UpdateWrapper<User> userUpdateWrapper = new UpdateWrapper<>();
	        //不使用实体类更新用户
	        userUpdateWrapper.eq("name", "王天风").eq("age", 41).set("age", 42);
	        int update = userMapper.update(null, userUpdateWrapper);
	        System.out.println("影响记录数:" + update);
	    }
	
	    @Test
	    public void updateByWrapperLambda() {
	        LambdaUpdateWrapper<User> userLambdaUpdateWrapper = Wrappers.<User>lambdaUpdate();
	        userLambdaUpdateWrapper.eq(User::getName, "王天风").eq(User::getAge, 42).set(User::getAge, 41);
	        int update = userMapper.update(null, userLambdaUpdateWrapper);
	        System.out.println("影响记录数:" + update);
	    }
	
	    @Test
	    public void updateByWrapperLambdaChain() {
	        boolean flag = new LambdaUpdateChainWrapper<>(userMapper)
	                .eq(User::getName, "王天风").eq(User::getAge, 41).set(User::getAge, 42).update();
	        System.out.println("更新:"+flag);
	    }
删除
@Test
	    public void deleteById() {
	        int rows = userMapper.deleteById(1178106259337924609L);
	        System.out.println("删除条数:" + rows);
	    }
	
	    @Test
	    public void deleteByMap() {
	        //DELETE FROM user WHERE name = ? AND age = ?
	        Map<String, Object> paramsMap = new HashMap<>();
	        paramsMap.put("name", "salesman");
	        paramsMap.put("age", 31);
	        int i = userMapper.deleteByMap(paramsMap);
	        System.out.println("删除条数:" + i);
	    }
	
	    @Test
	    public void deleteBatchIds() {
	        int i = userMapper.deleteBatchIds(Arrays.asList(58L, 66L));
	        System.out.println("删除条数:" + i);
	    }
	
	    @Test
	    public void deleteByWrapper() {
	        //DELETE FROM user WHERE age = ? OR age > ?
	        LambdaQueryWrapper<User> lambdaQueryWrapper = Wrappers.<User>lambdaQuery();
	        lambdaQueryWrapper.eq(User::getAge, 27).or().gt(User::getAge, 50);
	        int delete = userMapper.delete(lambdaQueryWrapper);
	        System.out.println("删除条数:" + delete);
	    }

AR模式

AR模式:简单来说, 就是通过实体类对象直接对表的增删改查操作

实体类继承Model类
 	@Data
	@EqualsAndHashCode(callSuper = false)//继承Model的时候使用
	@TableName("user")
	public class User extends Model<User> {//AR
	    private static final long serialVersionUID = 1L;//继承Model的时候使用
@Test
	    public void insert() {
	        User user = new User();
	        user.setName("engineer");
	        user.setAge(33);
	        user.setEmail("123@qq.com");
	        user.setManagerId(1088248166370832385L);
	        user.setCreateTime(LocalDateTime.now());
	        boolean insertFlag = user.insert();
	        System.out.println(insertFlag);
	    }
	
	    @Test
	    public void selectById() {
	        User user = new User();
	        User userSelect = user.selectById(1088248166370832385L);
	        System.out.println(userSelect == user);//false
	        System.out.println(userSelect);
	    }

主键策略

MyBatisPlus的主键策略封装在IdType枚举类中。

@Getter
public enum IdType {
    /**
     * 数据库ID自增
     */
    AUTO(0),
    /**
     * 该类型为未设置主键类型,未设置默认雪花算法
     */
    NONE(1),
    /**
     * 用户输入ID
     * <p>该类型可以通过自己注册自动填充插件进行填充</p>
     */
    INPUT(2),

    /* 以下3种类型、只有当插入对象ID 为空,才自动填充。雪花算法 */
    /**
     * 全局唯一ID (idWorker)
     */
    ID_WORKER(3),
    /**
     * 全局唯一ID (UUID)
     */
    UUID(4),
    /**
     * 字符串全局唯一ID (idWorker 的字符串表示)
     */
    ID_WORKER_STR(5);

    private final int key;

    IdType(int key) {
        this.key = key;
    }
}

在实体类中对应数据库中的主键id属性上标注注解TableId(type=‘xxx’)即可完成主键配置。

    @TableId(type = IdType.AUTO)
    private Long id;
全局主键策略实现

在application.yml增加全局主键策略配置

mybatis-plus:
  #全局主键策略配置
  global-config:
    db-config:
      id-type: uuid

如果全局策略和局部策略全都设置,局部策略优先。

通用 service

public interface UserService extends IService<User> {

}
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

}
@Autowired
    private UserService userService;

    @Test
    public void getOne() {
        //返回结果多个会报错
        //User one = userService.getOne(Wrappers.<User>lambdaQuery().gt(User::getAge, 25));
        //返回结果多个不会报错,只取第一个
        User one = userService.getOne(Wrappers.<User>lambdaQuery().gt(User::getAge, 25), false);
        System.out.println(one);
    }

    @Test
    public void Batch() {
        User user1 = new User();
        user1.setName("engineer3");
        user1.setAge(24);

        User user2 = new User();
        user2.setName("engineer4");
        user2.setAge(26);

        List<User> userList = Arrays.asList(user1, user2);
        boolean saveFlag = userService.saveBatch(userList);
        System.out.println(saveFlag);
    }

    @Test
    public void chain() {
        List<User> userList = userService.lambdaQuery().gt(User::getAge, 25).like(User::getName, "pro").list();
        userList.forEach(System.out::println);
    }

    @Test
    public void chain1() {
        boolean update = userService.lambdaUpdate().eq(User::getAge, 25).set(User::getAge, 26).update();
        System.out.println(update);
    }

    @Test
    public void chain2() {
        boolean remove = userService.lambdaUpdate().eq(User::getAge, 24).remove();
        System.out.println(remove);
    }
MybatisPlus中@TableField注解的使用详解 主要介绍了MybatisPlus中@TableField注解的使用详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 立即下载

相关推荐

AI 自动生成商业计划书:AIGC 如何助力创业者?

在创业的早期阶段,商业计划书(Business Plan)是至关重要的。它不仅用于吸引投资者、明确发展路径,还能帮助团队对业务模式、市场定位和财务预测有清晰认知。然而,撰写一份高质量的商业计划书往往需要投入大量时间和精力。如今,AIGC(AI Generated Content,人工智能生成内容)技术正在改变这一现状。借助 AIGC,创业者可以更快速、高效地创建商业计划书,并通过 AI 进行优化和数据分析。

2401_82808034的博客 3785

Mybatis中isNotNull与isNotEmpty的使用

isNotNull,就是不为null,也就是<>null isNotEmpty,就是不为空,也就是<>null,并且<>''(空字符串) <isNotEmpty prepend="AND" property="userName"> C.USER_NAME= #userName# </isNotEmpty> <i...

只喝酒不抽烟的博客 6465

构建Jetson AGX Xavier高精度时间同步网络:从GPS/PPS授时到PTP局域网分发

本文详细介绍了如何在Jetson AGX Xavier平台上构建高精度时间同步网络。通过GPS/PPS信号进行高精度授时,并利用NTP服务校准系统时钟,最终通过PTP协议在局域网内分发亚微秒级同步时间,为机器人、自动驾驶等多传感器融合系统提供统一的时间基准。

weixin_29191761的博客 276

mybatis-plus之条件构造器

在mybatis-plus中,条件构造器(Wrapper)是非常重要的 我们写一些复杂的 SQL 就可以使用它来代替! 案例一 查询 name 不能为空用户,并且邮箱不能为空,并且年龄大于22岁,使用 isNotNull .ge :表示大于 @Test void contextLoads(){ // 查询 name 不能为空用户,并且邮箱不为空的用户,年龄大于等于12 QueryWrapper<User> wrapper = new QueryWrapper<>()

qq_45726143的博客 1083

手把手教你配置UEFI Secure Boot:从密钥生成到系统验证(附避坑指南)

本文详细介绍了如何配置UEFI Secure Boot,从密钥生成到系统验证的全过程,包括PK、KEK等关键密钥的生成方法,以及常见问题的解决方案。通过实战案例和避坑指南,帮助用户有效提升系统启动安全性,防止恶意软件植入。

weixin_30776273的博客 343

模型训练篇 | 手把手教你使用ResNet训练自己数据集和推理,ResNet50通用物体分类识别,含完整代码和数据集,全网最详细教程

手把手教你使用ResNet训练自己数据集和推理,ResNet50通用物体分类识别,含完整代码和数据集,全网最详细教程。本篇文章将带你学习 ResNet50 模型构建、ResNet50训练自己数据集、数据集处理、推理和验证、模型剪枝与模型改进等。 本篇教程适配各种分类识别任务,可以说是一个通用的教程,只需修改自己的数据集即可完成自己领域的任务和系统实现。

在职AI算法工程师,擅长计算机视觉,YOLO目标检测、分割等,擅长web、pyqt界面可视化,好内容持续更新中,来这里跟大家一起学习,共同进步 742

【Mybatis】Mapper文件中sql不等于的写法

【Mybatis】Mapper文件中sql不等于的写法 认识误区:在xml文件中,是 不能直接使用 < 、>、& 的。因为会被语法检查而报错。 正确使用的两种方法 1. 第一种:转义 1. 小于 < &lt; 2. 大于 > &gt; 3. 不等于 <> &lt;&gt; 2. 第二种:<![CDATA[]]> <![CDATA[]]>这个标记所包含的内容即表示为 纯文本 实际例子: sql语句: sele

One_castle的博客 5708

Codex入门24-效率倍增秘籍(终极总结:10个让你开发速度翻倍的Codex高级技巧)

专栏收官之作!经过前23篇的系统学习,你已经掌握了 Codex CLI 的核心用法。本文浓缩10个实战验证的高级技巧:管道化提示词将复杂任务拆成递进指令链,模板化 SKILL.md 打造个人技能库,Shell 别名让操作快如闪电,多模型切换省钱又高效……这不是理论课,每个技巧都配有可直接运行的代码。掌握全部10招,构建你的 AI 开发工作流闭环,让开发速度真正翻倍!

yueyeguzhuo的专栏 191

MyBatis-Plus查询方法

普通查询 T selectById(Serializable id);(String Long Integer都有实现该接口) List selectBatchIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList); (只需要传入idList作为主键ID列表,不能为空) List sele...

qwredqwr的博客 2455

【RT-DETR实战】RT-DETR实战手记(200):端侧实时目标检测,下一步往哪儿走?

昨天深夜调一个模型部署,在树莓派4B上跑RT-DETR-nano,帧率死活卡在8FPS上不去。量化也做了,算子也优化了,内存对齐也检查了,可就是离实时检测的底线还差一截。盯着终端里跳动的数字,突然意识到——我们可能正在接近当前技术路径的瓶颈。端侧实时目标检测的下一个突破口,恐怕不在现有框架的修修补补里。

企鹅码农的专属播客,分享10多年的实战案例和经验解读,包含YOLO、RT-DETR、AI等各个工作领域。 187

ROS2 Nav2 - 模型预测路径积分控制器(MPPI)

这是一个预测控制器(局部轨迹规划器),用于实现模型预测路径积分(MPPI)算法,以跟踪具有自适应避障功能的路径。它包含基于插件的 critic 函数,可影响算法的行为。它由 Aleksei Budyakov 创建,由 Steve Macenski 为 Nav2 进行改编和开发。该插件实现了 nav2_core::Controller(控制器)接口,可在整个导航堆栈中作为控制器服务器的动作服务器(controller_server)中的局部轨迹规划器使用。据测定,该控制器可在中等英特尔处理器(第四代 i5)上

机器人控制与仿真应用 3915

MyBatis Plus入门笔记

无侵入,损耗小、强大的CRUD操作 支持Lambda形式调用、支持多种数据库 支持主键自动生成、支持ActiveRecord模式 支持自定义全局通用操作、支持关键词自动转义 内置代码生成器、内置分页插件、内置性能分析插件 内置全局拦截插件、内置SQL注入剥离器

out54537的博客 311

LangChain4j + MCP:从工具协议到生产级 Agent

这两年,很多团队都已经把「大模型问答」接入到系统里了:前端一个输入框,后端调一下 OpenAI / DeepSeek / 本地模型,返回一段回答——这类 「简单问答型」AI 功能它只能说,不会做:不会主动查数据库,不会调用你的接口,不会帮你真正执行脚本;面对复杂一点的需求,比如「帮我生成这个报表的 SQL 并执行一下」,普通 ChatGPT 式的问答就开始力不从心了。而Agent 智能体想解决的,就是这件事:不只是回答你「怎么做」,而是能自己思考、自己决定要不要用工具、再用工具把事做完。

OFFTime_we的博客 1154

MyBatis-Plus笔记-快速入门

mybatis-plus详解

m0_58684211的博客 1557

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

笔记:MyBatis plus入门

文章目录maven依赖注解支持CRUD 接口Service CRUD 接口SaveSaveOrUpdateRemoveUpdateGetListPageCount链式写法queryupdateMapper CRUD 接口InsertDeleteUpdateSelect条件构造器分页插件案例分析查询实例条件判断 condition的使用统计查询(groupby)lambda条件构造器使用条件构造器自...

Mr_zzr的博客 1618

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Mybatis-Plus入门笔记

快速开始 1. 新建springboot项目导入pom依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

weixin_44105802的博客 305

mybatis学习笔记——mybatis-plus快速入门

mybatis-plus快速入门

飞!!!的博客 1078

mybatis-plus的快速入门笔记

各种各样的sql需要写,什么分页啊,条件查询啊,真的太难了,之后发现有个mp,自动帮我们写sql,挺好用的,可能其他人喜欢jpa,可以都去了解一下。 官网https://mp.baomidou.com/ 简单使用 基本配置 # 配置日志 默认控制台 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl # 配置逻辑删除 # 逻辑已删除值(默认为 1) mybatis-plus.global-co.

L_xioabai_L的博客 812

MyBatis-Plus入门笔记

@TableField(exist = false) 忽略一些字段(数据库没有但又是必须的) 1: @TableName(“dic_license”) : 指定实体对应的数据库表 2: @TableId 指定数据对应数据库的主键队列 3: @TableField(“name”) 直接指定对应数据库的列 4: @TableField(exist=false) private Stri...

weixin_45947518的博客 272

Mybatis-plus最强入门笔记

Mybatisplus 概述 基础 ssm之后 可以节省大量的工作时间 所有的crud代码都没了 自动化完成 Jpa tk-mapper 都是差不多的 偷懒的 是什么? 官网看看 特性:无侵入 损耗小 强大的crud lambda 主键自动生成 支持多种数据库 内置分页插件 快速入门 使用第三方组件 倒入对应的依赖 研究依赖如何配置 代码如何编写 提高扩展技术能力 先体验一下 创一个库 表user 真是开发version字段需要 乐观锁 Deleted 逻辑删除 Gmt_create gmt_mod

LeBronJJJ的博客 503

mybatis-plus入门笔记

创建数据库初始化项目添加依赖(数据库依赖看自己的数据库来导入)</</</</</</</</配置传统的mybatis开发需要创建一个实体类;创建mapper接口,创建mapper.xml实现。myabtis-plus已经帮助我们做好了增删改查,我们需要在接口上继承一个baseMapper,并传递一个需要被操作的对象泛型。添加注解@Repostitory注册到spring容器,添加注解@Mapper被mybatisplus扫描或者在启动类上添加注解@MapperScan()设置扫描路径。

qq_31240423的博客 677

MyBatis-Plus入门学习笔记

各方

weixin_44735825的博客 510

MyBatis-Plus入门笔记(一)

MyBatis-Plus(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。

qq_43000128的博客 1059

尚硅谷MyBatis-Plus笔记001【简介、入门案例、基本CRUD】

MyBatisPlus

upward 1329
下一篇: 多线程入门笔记
JSFOVR
博客等级 码龄8年 0粉丝 3原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值