v1.0.0 prepare

This commit is contained in:
开源海哥 2023-03-11 15:37:17 +08:00
parent e5f87b8212
commit d9e7b7d43f
2 changed files with 16 additions and 7 deletions

View File

@ -162,6 +162,10 @@ public class FlexConfiguration extends Configuration {
*/ */
private MappedStatement replaceRowKeyGenerator(MappedStatement ms) { private MappedStatement replaceRowKeyGenerator(MappedStatement ms) {
//执行原生 SQL不需要为其设置主键生成器
if (ms.getId().endsWith("BySql")) {
return ms;
}
KeyGenerator keyGenerator = new RowKeyGenerator(ms); KeyGenerator keyGenerator = new RowKeyGenerator(ms);
if (ms.getId().endsWith("insertBatchWithFirstRowColumns")) { if (ms.getId().endsWith("insertBatchWithFirstRowColumns")) {

View File

@ -49,7 +49,6 @@ public class MybatisFlexStarter {
System.out.println(row); System.out.println(row);
//新增一条数据自增 //新增一条数据自增
Row newRow = Row.ofKey(RowKey.ID_AUTO) // id 自增 Row newRow = Row.ofKey(RowKey.ID_AUTO) // id 自增
.set("user_name", "lisi") .set("user_name", "lisi")
@ -63,6 +62,12 @@ public class MybatisFlexStarter {
System.out.println(">>>>>>newRow.id: " + newRow.get("id")); System.out.println(">>>>>>newRow.id: " + newRow.get("id"));
bootstrap.execute(RowMapper.class, rowMapper ->
rowMapper.insertBySql("insert into tb_account(user_name,age,birthday) values (?,?,?)"
, "张三"
, 18
, new Date()));
List<Row> newRowList = new ArrayList<>(); List<Row> newRowList = new ArrayList<>();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
@ -82,13 +87,13 @@ public class MybatisFlexStarter {
List<Row> rows = bootstrap.execute(RowMapper.class, rowMapper -> List<Row> rows = bootstrap.execute(RowMapper.class, rowMapper ->
rowMapper.selectAll("tb_account")); rowMapper.selectAll("tb_account"));
System.out.println("rows count: " + rows.size()); //8 System.out.println("rows count: " + rows.size()); //9
System.out.println(rows); System.out.println(rows);
//分页查询 2 每页 3 条数据 //分页查询 2 每页 4 条数据
Page<Row> rowPage = bootstrap.execute(RowMapper.class, rowMapper -> Page<Row> rowPage = bootstrap.execute(RowMapper.class, rowMapper ->
rowMapper.paginate("tb_account", 2, 3, QueryWrapper.create())); rowMapper.paginate("tb_account", 2, 4, QueryWrapper.create()));
System.out.println(rowPage); System.out.println(rowPage);
} }
} }