mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
test: 测试 IAU28L 问题。
This commit is contained in:
parent
e49ec138f2
commit
16c5bca1a1
@ -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);
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
package com.mybatisflex.test.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 复杂查询接收类
|
||||
* <a href="https://gitee.com/mybatis-flex/mybatis-flex/issues/IAU28L">演示问题</a>。
|
||||
*
|
||||
* @author 王帅
|
||||
* @since 2024-10-03
|
||||
*/
|
||||
@SuppressWarnings({"LombokGetterMayBeUsed", "LombokSetterMayBeUsed"})
|
||||
public class AccountView {
|
||||
|
||||
private Long id;
|
||||
private String userName;
|
||||
private Date birthday;
|
||||
|
||||
private List<Account> 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<Account> getAccountList() {
|
||||
return accountList;
|
||||
}
|
||||
|
||||
public void setAccountList(List<Account> accountList) {
|
||||
this.accountList = accountList;
|
||||
}
|
||||
|
||||
}
|
||||
@ -26,4 +26,19 @@
|
||||
select count(*) from `tb_account` ${qwSql}
|
||||
</select>
|
||||
|
||||
<resultMap id="AccountViewObject" type="com.mybatisflex.test.model.AccountView">
|
||||
<id property="id" column="id"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="birthday" column="birthday"/>
|
||||
<association property="accountList" column="id" select="selectAssociation"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectViewObject" resultMap="AccountViewObject">
|
||||
select id, user_name, birthday from tb_account where id = 1
|
||||
</select>
|
||||
|
||||
<select id="selectAssociation" resultType="com.mybatisflex.test.model.Account">
|
||||
select * from tb_account where id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -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<Account> accounts = new ArrayList<>();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user