在MyBatis中,tinyint和integer都是数据库中常用的数据类型,它们之间的区别在于存储的范围和长度不同。 tinyint:是一种较小的整数类型,通常占用1个字节(8 bits),范围为-128到127。在数据库存储时,通常用来表示布尔值,即0或1。 integer:是一种较大的整数类型,通常占用4个字节(32 bits),范围为-2147483648到21474...
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL DEFAULT '' COMMENT '用户名', `money` int(26) NOT NULL DEFAULT '0' COMMENT '钱', `is_deleted` tinyint(1) NOT NULL DEFAULT '0', `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间...
int getStudentByCondition(String studentName,Interge studentAge); //@Param可以不按照顺序,@Param中有值按照值来,没值的话按照变量名称 int getStudentByCondition(@Param("name") String studentName,@Param("age") Interge studentAge); //返回Map类型单条数据 Map<String,Object> getUserById(Interger id)...
task_status tinyint(1) default 0 not null comment '任务状态:1启用,2禁用', mq_switch tinyint(1) default 0 not null comment '是否发送消息至MQ:1发送,0不发送', isactive tinyint(1) default 1 not null comment '逻辑删除', inserttime datetime default CURRENT_TIMESTAMP not null comment '插入...
在数据库表中,我们需要添加一个用于表示逻辑删除状态的字段。例如,我们可以添加一个名为deleted的tinyint类型字段,默认值为0。 在实体类(这里是Blog类)中,我们使用Lombok来减少getter和setter方法的编写工作。以下是一个示例: import com.baomidou.mybatisplus.annotation.TableLogic;import com.baomidou.mybatisplus.ann...
`gender` tinyint(2) NOT NULL DEFAULT 0 COMMENT '性别,0:女 1:男', PRIMARY KEY (`id`) ) COMMENT= '用户表'; INSERT INTO `t_user` (`id`, `name`, `age`, `gender`) VALUES (1, '犬小哈', 30, 1); INSERT INTO `t_user` (`id`, `name`, `age`, `gender`) VALUES (2, '...
`isDeleted` tinyint(1) NOT NULL DEFAULT '0', `created` varchar(13) NOT NULL DEFAULT '0', `updated` varchar(13) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `story_t0` ( ...
,`create_time`datetimeCOMMENT'创建时间',`update_time`datetimeCOMMENT'更新时间',`deleted`tinyint...
*/privateIntegergender; } 讲解一下实体类中用到的注解: @TableName 表名注解 作用:标识实体类对应的表。 TIP : 当实体类名称和实际表名一致时,如实体名为User, 表名为user,可不用添加该注解,Mybatis Plus 会自动识别并映射到该表。 当实体类名称和实际表名不一致时,如实体名为User, 表名为t_user,需...
@Testpublic void testInsert() { User user = new User(); user.setName("字母哥"); user.setAge(18); int row = userMapper.insert(user);} deleted采用默认值0(未删除),新插入的数据都是未删除的数据 3.2.删除一条记录:执行如下Mybatis Plus API删除操作 userMapper.deleteById(...