build: v1.8.8 release (^.^)YYa!!

This commit is contained in:
Michael Yang 2024-04-18 19:58:26 +08:00
parent cfd48ae10a
commit dd58df4844
16 changed files with 56 additions and 56 deletions

View File

@ -98,15 +98,15 @@ public class DbTest {
account.setAge(1);
List<Account> accounts = new ArrayList<>();
accounts.add(account);
Account account2 = UpdateEntity.of(Account.class, 2);
account2.setAge(2);
UpdateWrapper updateWrapper = UpdateWrapper.of(account2);
Account account82 = UpdateEntity.of(Account.class, 2);
account82.setAge(2);
UpdateWrapper updateWrapper = UpdateWrapper.of(account82);
updateWrapper.setRaw("age", "age+1");
accounts.add(account2);
Account account3 = new Account();
account3.setId(3L);
account3.setAge(4);
accounts.add(account3);
accounts.add(account82);
Account account83 = new Account();
account83.setId(3L);
account83.setAge(4);
accounts.add(account83);
Db.updateEntitiesBatch(accounts);
} catch (Exception e) {
assert false;

View File

@ -29,7 +29,6 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import javax.sql.DataSource;
import java.util.List;
import java.util.function.Supplier;
import static com.mybatisflex.test.table.AccountTableDef.ACCOUNT;
import static com.mybatisflex.test.table.ArticleTableDef.ARTICLE;

View File

@ -30,6 +30,7 @@ import java.util.List;
import static com.mybatisflex.test.table.AccountTableDef.ACCOUNT;
public class UpdateWrapperTest {
public static void main(String[] args) {
@ -71,10 +72,10 @@ public class UpdateWrapperTest {
System.out.println("//////////account3");
Account account3 = UpdateEntity.of(Account.class, 1);
UpdateWrapper<Account> wrapper3 = (UpdateWrapper) account3;
Account account83 = UpdateEntity.of(Account.class, 1);
UpdateWrapper<Account> wrapper3 = (UpdateWrapper) account83;
wrapper3.setRaw(Account::getAge, "age + 1");
accountMapper.update(account3);
accountMapper.update(account83);
List<Account> accounts3 = accountMapper.selectAll();
System.out.println(accounts3);
@ -82,10 +83,10 @@ public class UpdateWrapperTest {
System.out.println("//////////account4");
Account account4 = UpdateEntity.of(Account.class, 1);
UpdateWrapper wrapper4 = (UpdateWrapper) account4;
Account account84 = UpdateEntity.of(Account.class, 1);
UpdateWrapper wrapper4 = (UpdateWrapper) account84;
wrapper4.setRaw(ACCOUNT.AGE, ACCOUNT.AGE.add(1));
accountMapper.update(account4);
accountMapper.update(account84);
List<Account> accounts4 = accountMapper.selectAll();
System.out.println(accounts4);

View File

@ -24,6 +24,7 @@ import org.nustaq.serialization.FSTConfiguration;
import static com.mybatisflex.test.table.AccountTableDef.ACCOUNT;
public class WrapperSerializeTest {
public static void main(String[] args) throws Exception {

View File

@ -33,7 +33,7 @@ public class Book implements Serializable {
private String content;
@RelationManyToOne(selfField = "accountId", targetField = "id")
private Account account;
private RelationAccount account;
public Long getId() {
return id;
@ -67,11 +67,11 @@ public class Book implements Serializable {
this.content = content;
}
public Account getAccount() {
public RelationAccount getAccount() {
return account;
}
public void setAccount(Account account) {
public void setAccount(RelationAccount account) {
this.account = account;
}

View File

@ -24,8 +24,8 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
@Table(value = "tb_account")
public class Account implements Serializable {
@Table(value = "tb_relation_account")
public class RelationAccount implements Serializable {
@Id
private Long id;

View File

@ -36,7 +36,7 @@ public class Role implements Serializable {
selfField = "id", joinSelfColumn = "role_id",
targetField = "id", joinTargetColumn = "account_id"
)
private List<Account> accounts;
private List<RelationAccount> accounts;
public Long getId() {
return id;
@ -54,11 +54,11 @@ public class Role implements Serializable {
this.name = name;
}
public List<Account> getAccounts() {
public List<RelationAccount> getAccounts() {
return accounts;
}
public void setAccounts(List<Account> accounts) {
public void setAccounts(List<RelationAccount> accounts) {
this.accounts = accounts;
}

View File

@ -6,7 +6,6 @@ import com.mybatisflex.core.audit.ConsoleMessageCollector;
import com.mybatisflex.core.datasource.DataSourceKey;
import com.mybatisflex.mapper.Account6Mapper;
import org.apache.ibatis.logging.stdout.StdOutImpl;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.assertj.core.api.WithAssertions;
import org.junit.After;
import org.junit.Assert;
@ -17,7 +16,6 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
/**

View File

@ -23,13 +23,13 @@ import com.mybatisflex.core.datasource.DataSourceKey;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.relation.RelationManager;
import com.mybatisflex.test.relation.mapper.AccountMapper;
import com.mybatisflex.test.relation.mapper.BookMapper;
import com.mybatisflex.test.relation.mapper.MenuMapper;
import com.mybatisflex.test.relation.onetoone.Account;
import com.mybatisflex.test.relation.mapper.RelationAccountMapper;
import com.mybatisflex.test.relation.onetoone.AccountDTO;
import com.mybatisflex.test.relation.onetoone.Book;
import com.mybatisflex.test.relation.onetoone.Menu;
import com.mybatisflex.test.relation.onetoone.RelationAccount;
import lombok.SneakyThrows;
import net.javacrumbs.jsonunit.assertj.JsonAssertions;
import org.apache.commons.io.FileUtils;
@ -51,7 +51,7 @@ import static com.mybatisflex.test.relation.onetoone.table.MenuTableDef.MENU;
public class RelationsTest implements WithAssertions {
private AccountMapper accountMapper;
private RelationAccountMapper relationAccountMapper;
private BookMapper bookMapper;
private MenuMapper menuMapper;
private EmbeddedDatabase dataSource;
@ -75,14 +75,14 @@ public class RelationsTest implements WithAssertions {
MybatisFlexBootstrap bootstrap = MybatisFlexBootstrap.getInstance()
.setDataSource(DATA_SOURCE_KEY, dataSource)
.addMapper(AccountMapper.class)
.addMapper(RelationAccountMapper.class)
.addMapper(BookMapper.class)
.addMapper(MenuMapper.class)
.start();
DataSourceKey.use(DATA_SOURCE_KEY);
accountMapper = bootstrap.getMapper(AccountMapper.class);
relationAccountMapper = bootstrap.getMapper(RelationAccountMapper.class);
bookMapper = bootstrap.getMapper(BookMapper.class);
menuMapper = bootstrap.getMapper(MenuMapper.class);
}
@ -96,7 +96,7 @@ public class RelationsTest implements WithAssertions {
@Test
@SneakyThrows
public void testOneToOne() {
List<com.mybatisflex.test.relation.onetoone.Account> accounts = accountMapper.selectAllWithRelations();
List<RelationAccount> accounts = relationAccountMapper.selectAllWithRelations();
assertThat(accounts).hasSize(5);
assertRelationResult(accounts, "relation/result/account-relation-result.json");
}
@ -114,18 +114,18 @@ public class RelationsTest implements WithAssertions {
@Test
public void testManyToMany1() {
List<com.mybatisflex.test.relation.onetoone.Account> accounts = accountMapper.selectAll();
List<RelationAccount> accounts = relationAccountMapper.selectAll();
assertThat(accounts).hasSize(5)
.extracting(Account::getId)
.extracting(RelationAccount::getId)
.containsExactly(1L, 2L, 3L, 4L, 5L);
RelationManager.queryRelations(accountMapper, accounts);
RelationManager.queryRelations(relationAccountMapper, accounts);
assertRelationResult(accounts, "relation/result/account-relation-result.json");
}
// @Test
// @Test
public void testAsDto() {
List<com.mybatisflex.test.relation.onetoone.AccountDTO> accounts = accountMapper.selectListWithRelationsByQueryAs(QueryWrapper.create(), AccountDTO.class);
List<com.mybatisflex.test.relation.onetoone.AccountDTO> accounts = relationAccountMapper.selectListWithRelationsByQueryAs(QueryWrapper.create(), AccountDTO.class);
assertRelationResult(accounts, "relation/result/accountDto-relation-result.json");
}
@ -150,7 +150,7 @@ public class RelationsTest implements WithAssertions {
@Test
public void testPaginate() {
Page<Account> accountPage = accountMapper.paginateWithRelations(1, 2, QueryWrapper.create());
Page<RelationAccount> accountPage = relationAccountMapper.paginateWithRelations(1, 2, QueryWrapper.create());
assertRelationResult(accountPage.getRecords(), "relation/result/account-page-relation-result.json");
}

View File

@ -37,7 +37,8 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import java.util.List;
import static com.mybatisflex.test.relation.onetoone.table.AccountTableDef.ACCOUNT;
import static com.mybatisflex.test.table.AccountTableDef.ACCOUNT;
public class RowTest implements WithAssertions {

View File

@ -1,4 +1,4 @@
INSERT INTO tb_account
INSERT INTO tb_relation_account
VALUES (1, '孙悟空', 18),
(2, '猪八戒', 19),
(3, '沙和尚', 19),

View File

@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS `tb_account`
CREATE TABLE IF NOT EXISTS `tb_relation_account`
(
`id` INTEGER,
`user_name` VARCHAR(100),