| <dependency> |
| <groupId>com.baomidou</groupId> |
| <artifactId>mybatis-plus-boot-starter</artifactId> |
| </dependency> |
| mybatis-plus: |
| global-config: |
| db-config: |
| id-type: ASSIGN_ID |
| capital-mode: true |
| configuration: |
| log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
| @Configuration |
| public class MybatisPlusConfig { |
| |
| @Bean |
| public MybatisPlusInterceptor mybatisPlusInterceptor() { |
| MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); |
| return interceptor; |
| } |
| } |
| @Slf4j |
| @SpringBootTest |
| class ExecutionTest { |
| |
| @Autowired |
| private StudentMapper studentMapper; |
| |
| @Test |
| void test() { |
| studentMapper.selectList(new QueryWrapper<>()); |
| studentMapper.deleteById(1L); |
| Student student = new Student(); |
| student.setName("test_update"); |
| studentMapper.insert(new Student(1L, "test", 12)); |
| studentMapper.update(student, new QueryWrapper<Student>().eq("id", 1L)); |
| try { |
| studentMapper.update(new Student(), new QueryWrapper<>()); |
| } catch (MyBatisSystemException e) { |
| } |
| try { |
| studentMapper.delete(new QueryWrapper<>()); |
| } catch (MyBatisSystemException e) { |
| System.err.println("执行了全表删除拦截,删除无效!异常:" + e.getMessage()); |
| } |
| Assertions.assertTrue(CollectionUtils.isNotEmpty(studentMapper.selectList(new QueryWrapper<>())), "数据都被删掉了.(┬_┬)"); |
| } |
| } |
| SELECT ID,NAME,AGE FROM student |
| ==> Parameters: |
| <== Total: 0 |
| DELETE FROM student WHERE ID=? |
| ==> Parameters: 1(Long) |
| <== Updates: 0 |
| INSERT INTO student ( ID, NAME, AGE ) VALUES ( ?, ?, ? ) |
| ==> Parameters: 1(Long), test(String), 12(Integer) |
| <== Updates: 1 |
| UPDATE student SET NAME=? WHERE (id = ?) |
| ==> Parameters: test_update(String), 1(Long) |
| <== Updates: 1 |
| 执行了全表删除拦截,删除无效!异常:nested exception is org.apache.ibatis.exceptions.PersistenceException: |
| |
| |
| |
| |
| |
| SELECT ID,NAME,AGE FROM student |
| ==> Parameters: |
| <== Columns: ID, NAME, AGE |
| <== Row: 1, test_update, 12 |
| <== Total: 1 |
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术