mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -145,9 +145,9 @@ public class DialectRunner implements Serializable {
|
||||
* @throws DbRuntimeException SQL执行异常
|
||||
*/
|
||||
public int insertOrUpdate(final Connection conn, final Entity record, final String... keys) throws DbRuntimeException {
|
||||
final Entity where = record.filter(keys);
|
||||
final Entity where = record.filterNew(keys);
|
||||
if (MapUtil.isNotEmpty(where) && count(conn, Query.of(where)) > 0) {
|
||||
return update(conn, record, where);
|
||||
return update(conn, record.removeNew(keys), where);
|
||||
} else {
|
||||
return insert(conn, record)[0];
|
||||
}
|
||||
|
@@ -107,7 +107,10 @@ public class Entity extends Dict {
|
||||
/* 字段名列表,用于限制加入的字段的值 */
|
||||
private Set<String> fieldNames;
|
||||
|
||||
// --------------------------------------------------------------- Constructor start
|
||||
// region ----- Constructor
|
||||
/**
|
||||
* 构造
|
||||
*/
|
||||
public Entity() {
|
||||
}
|
||||
|
||||
@@ -132,7 +135,7 @@ public class Entity extends Dict {
|
||||
super(caseInsensitive);
|
||||
this.tableName = tableName;
|
||||
}
|
||||
// --------------------------------------------------------------- Constructor end
|
||||
// endregion
|
||||
|
||||
// --------------------------------------------------------------- Getters and Setters start
|
||||
|
||||
@@ -259,7 +262,7 @@ public class Entity extends Dict {
|
||||
* @since 4.0.10
|
||||
*/
|
||||
@Override
|
||||
public Entity filter(final String... keys) {
|
||||
public Entity filterNew(final String... keys) {
|
||||
final Entity result = new Entity(this.tableName);
|
||||
result.setFieldNames(this.fieldNames);
|
||||
|
||||
@@ -271,6 +274,11 @@ public class Entity extends Dict {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity removeNew(final String... keys) {
|
||||
return (Entity) super.removeNew(keys);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------- Put and Set start
|
||||
@Override
|
||||
public Entity set(final String field, final Object value) {
|
||||
|
Reference in New Issue
Block a user