diff --git a/CHANGELOG.md b/CHANGELOG.md index b8c55d5208..8fc7f2ee4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## [v3.5.4.1] 2023.11.4 +- fix: 修复Aop增强Mapper层导致的转换错误. + ## [v3.5.4] 2023.10.22 - fix: 修复Insert无字段时执行SQL报错. diff --git a/changelog-temp.md b/changelog-temp.md index ef8c6ffdf6..8b13789179 100644 --- a/changelog-temp.md +++ b/changelog-temp.md @@ -1 +1 @@ -* fix: 修复Aop增强Mapper层导致的转换错误. + diff --git a/gradle.properties b/gradle.properties index 44238a5151..54e6f1165b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -APP_VERSION=3.5.5-SNAPSHOT +APP_VERSION=3.5.4.1 APP_GROUP=com.baomidou signing.keyId=1FD337F9 signing.password=243194995 diff --git a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/AppConfig.java b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/AppConfig.java new file mode 100644 index 0000000000..7549d5a90c --- /dev/null +++ b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/AppConfig.java @@ -0,0 +1,40 @@ + +package com.baomidou.mybatisplus.test.h2.issues.repositoryscan; + +import com.baomidou.mybatisplus.core.MybatisConfiguration; +import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; +import org.apache.ibatis.session.SqlSessionFactory; +import org.h2.Driver; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.SimpleDriverDataSource; + +import javax.sql.DataSource; + +/** + * @author nieqiurong + */ +@Configuration +@ComponentScan("com.baomidou.mybatisplus.test.h2.issues.repositoryscan") +public class AppConfig { + + @Bean + public DataSource dataSource() { + SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); + dataSource.setDriver(new Driver()); + dataSource.setUrl("jdbc:h2:mem:testa;MODE=mysql;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"); + dataSource.setUsername("sa"); + dataSource.setPassword(""); + return dataSource; + } + + @Bean + public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { + MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean(); + mybatisSqlSessionFactoryBean.setDataSource(dataSource); + mybatisSqlSessionFactoryBean.setConfiguration(new MybatisConfiguration()); + return mybatisSqlSessionFactoryBean.getObject(); + } + +} diff --git a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/AppConfigWithMapperScan.java b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/AppConfigWithMapperScan.java new file mode 100644 index 0000000000..789122c701 --- /dev/null +++ b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/AppConfigWithMapperScan.java @@ -0,0 +1,43 @@ + +package com.baomidou.mybatisplus.test.h2.issues.repositoryscan; + +import com.baomidou.mybatisplus.core.MybatisConfiguration; +import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; +import org.apache.ibatis.session.SqlSessionFactory; +import org.h2.Driver; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.SimpleDriverDataSource; +import org.springframework.stereotype.Repository; + +import javax.sql.DataSource; + +/** + * @author nieqiurong + */ +@Configuration +@ComponentScan("com.baomidou.mybatisplus.test.h2.issues.repositoryscan") +@MapperScan(value = "com.baomidou.mybatisplus.test.h2.issues.repositoryscan.mapper", annotationClass = Repository.class) +public class AppConfigWithMapperScan { + + @Bean + public DataSource dataSource() { + SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); + dataSource.setDriver(new Driver()); + dataSource.setUrl("jdbc:h2:mem:testa;MODE=mysql;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"); + dataSource.setUsername("sa"); + dataSource.setPassword(""); + return dataSource; + } + + @Bean + public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { + MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean(); + mybatisSqlSessionFactoryBean.setDataSource(dataSource); + mybatisSqlSessionFactoryBean.setConfiguration(new MybatisConfiguration()); + return mybatisSqlSessionFactoryBean.getObject(); + } + +} diff --git a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/RepositoryDefaultScanTest.java b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/RepositoryDefaultScanTest.java new file mode 100644 index 0000000000..2982b621a1 --- /dev/null +++ b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/RepositoryDefaultScanTest.java @@ -0,0 +1,44 @@ +package com.baomidou.mybatisplus.test.h2.issues.repositoryscan; + +import com.baomidou.mybatisplus.test.h2.issues.repositoryscan.entity.Demo; +import com.baomidou.mybatisplus.test.h2.issues.repositoryscan.service.IDemoRepositoryService; +import org.apache.ibatis.jdbc.SqlRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import javax.sql.DataSource; +import java.sql.SQLException; +import java.util.List; + +/** + * @author nieqiurong + */ +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = {AppConfig.class}) +public class RepositoryDefaultScanTest { + + @Autowired + private IDemoRepositoryService demoService; + + @Autowired + private DataSource dataSource; + + @Test + void test() throws SQLException { + new SqlRunner(dataSource.getConnection()).run( + """ + CREATE TABLE IF NOT EXISTS demo ( + id BIGINT NOT NULL AUTO_INCREMENT, + name VARCHAR(30) NULL DEFAULT NULL , + PRIMARY KEY (id) + ); + """ + ); + demoService.save(new Demo()); + demoService.saveBatch(List.of(new Demo())); + } + +} diff --git a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/RepositoryMapperScanTest.java b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/RepositoryMapperScanTest.java new file mode 100644 index 0000000000..b4be75381f --- /dev/null +++ b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/RepositoryMapperScanTest.java @@ -0,0 +1,44 @@ +package com.baomidou.mybatisplus.test.h2.issues.repositoryscan; + +import com.baomidou.mybatisplus.test.h2.issues.repositoryscan.entity.Demo; +import com.baomidou.mybatisplus.test.h2.issues.repositoryscan.service.IDemoRepositoryService; +import org.apache.ibatis.jdbc.SqlRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import javax.sql.DataSource; +import java.sql.SQLException; +import java.util.List; + +/** + * @author nieqiurong + */ +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = {AppConfigWithMapperScan.class}) +public class RepositoryMapperScanTest { + + @Autowired + private IDemoRepositoryService demoService; + + @Autowired + private DataSource dataSource; + + @Test + void test() throws SQLException { + new SqlRunner(dataSource.getConnection()).run( + """ + CREATE TABLE IF NOT EXISTS demo ( + id BIGINT NOT NULL AUTO_INCREMENT, + name VARCHAR(30) NULL DEFAULT NULL , + PRIMARY KEY (id) + ); + """ + ); + demoService.save(new Demo()); + demoService.saveBatch(List.of(new Demo())); + } + +} diff --git a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/entity/Demo.java b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/entity/Demo.java new file mode 100644 index 0000000000..5bb5bf735b --- /dev/null +++ b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/entity/Demo.java @@ -0,0 +1,15 @@ +package com.baomidou.mybatisplus.test.h2.issues.repositoryscan.entity; + +import lombok.Data; + +/** + * @author nieqiurong + */ +@Data +public class Demo { + + private Long id; + + private String name; + +} diff --git a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/mapper/DemoRepositoryMapper.java b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/mapper/DemoRepositoryMapper.java new file mode 100644 index 0000000000..84fa774740 --- /dev/null +++ b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/mapper/DemoRepositoryMapper.java @@ -0,0 +1,13 @@ +package com.baomidou.mybatisplus.test.h2.issues.repositoryscan.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.test.h2.issues.repositoryscan.entity.Demo; +import org.springframework.stereotype.Repository; + +/** + * @author nieqiurong + */ +@Repository +public interface DemoRepositoryMapper extends BaseMapper { + +} diff --git a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/service/IDemoRepositoryService.java b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/service/IDemoRepositoryService.java new file mode 100644 index 0000000000..3ad0517fe5 --- /dev/null +++ b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/service/IDemoRepositoryService.java @@ -0,0 +1,11 @@ +package com.baomidou.mybatisplus.test.h2.issues.repositoryscan.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.test.h2.issues.repositoryscan.entity.Demo; + +/** + * @author nieqiurong + */ +public interface IDemoRepositoryService extends IService { + +} diff --git a/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/service/impl/DemoRepositoryServiceImpl.java b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/service/impl/DemoRepositoryServiceImpl.java new file mode 100644 index 0000000000..0ac30d05d1 --- /dev/null +++ b/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/issues/repositoryscan/service/impl/DemoRepositoryServiceImpl.java @@ -0,0 +1,15 @@ +package com.baomidou.mybatisplus.test.h2.issues.repositoryscan.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.baomidou.mybatisplus.test.h2.issues.repositoryscan.entity.Demo; +import com.baomidou.mybatisplus.test.h2.issues.repositoryscan.mapper.DemoRepositoryMapper; +import com.baomidou.mybatisplus.test.h2.issues.repositoryscan.service.IDemoRepositoryService; +import org.springframework.stereotype.Service; + +/** + * @author nieqiurong + */ +@Service +public class DemoRepositoryServiceImpl extends ServiceImpl implements IDemoRepositoryService { + +}