diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/mapper/MyAccountMapper.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/mapper/MyAccountMapper.java index 5f5ad57a..45cafd2f 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/mapper/MyAccountMapper.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/mapper/MyAccountMapper.java @@ -17,6 +17,8 @@ package com.mybatisflex.test.mapper; import com.mybatisflex.test.model.Account; +import com.mybatisflex.test.model.AccountDto; +import com.mybatisflex.test.model.AccountView; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -25,7 +27,9 @@ import java.util.Map; public interface MyAccountMapper extends AccountMapper { -// AccountDto selectByName(@Param("name") String name); + AccountDto selectByName(@Param("name") String name); + + AccountView selectViewObject(); @Select("select * from tb_account where id = #{id} and id =#{id}") Account selectById(@Param("id") Object id); diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountView.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountView.java new file mode 100644 index 00000000..ed722e42 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountView.java @@ -0,0 +1,54 @@ +package com.mybatisflex.test.model; + +import java.util.Date; +import java.util.List; + +/** + * 复杂查询接收类 + * 演示问题。 + * + * @author 王帅 + * @since 2024-10-03 + */ +@SuppressWarnings({"LombokGetterMayBeUsed", "LombokSetterMayBeUsed"}) +public class AccountView { + + private Long id; + private String userName; + private Date birthday; + + private List accountList; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public Date getBirthday() { + return birthday; + } + + public void setBirthday(Date birthday) { + this.birthday = birthday; + } + + public List getAccountList() { + return accountList; + } + + public void setAccountList(List accountList) { + this.accountList = accountList; + } + +} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/mapper/accountMapper.xml b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/mapper/accountMapper.xml index 43229d97..7cdea25c 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/mapper/accountMapper.xml +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/mapper/accountMapper.xml @@ -26,4 +26,19 @@ select count(*) from `tb_account` ${qwSql} + + + + + + + + + + + diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java index b943336e..e5e67a2f 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java @@ -17,6 +17,8 @@ package com.mybatisflex.test.mapper; import com.mybatisflex.test.model.Account; +import com.mybatisflex.test.model.AccountView; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -37,6 +39,12 @@ class MyAccountMapperTest { @Autowired private MyAccountMapper mapper; + @Test + void complexSelect() { + AccountView accountView = Assertions.assertDoesNotThrow(() -> mapper.selectViewObject()); + System.out.println(accountView); + } + @Test void insertBatch() { List accounts = new ArrayList<>();