Skip to content

Commit 41f874c

Browse files
committed
refactor: 优化
Signed-off-by: zhouhao <[email protected]>
1 parent bfe6bf7 commit 41f874c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

hsweb-easy-orm-rdb/src/main/java/org/hswebframework/ezorm/rdb/mapping/defaults/DefaultRepository.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ protected InsertResultOperator doInsert(E data) {
184184

185185
return EventResultOperator.create(
186186
() -> {
187-
for (Map.Entry<String, String> entry : mapping.getColumnPropertyMapping().entrySet()) {
188-
String column = entry.getKey();
189-
String property = entry.getValue();
190-
insert.value(column, getInsertColumnValue(data, property));
191-
}
187+
insert.columns(getProperties());
188+
insert.values(Stream
189+
.of(getProperties())
190+
.map(property -> getInsertColumnValue(data, property))
191+
.toArray());
192192
return insert.execute();
193193
},
194194
InsertResultOperator.class,

hsweb-easy-orm-rdb/src/main/java/org/hswebframework/ezorm/rdb/mapping/defaults/DefaultSyncRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void insert(E data) {
8686

8787
@Override
8888
public int insertBatch(Collection<E> batch) {
89-
if (batch.size() == 0) {
89+
if (batch.isEmpty()) {
9090
return 0;
9191
}
9292
return doInsert(batch).sync();

0 commit comments

Comments
 (0)