mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fixed insertSelective error close #12
This commit is contained in:
parent
d3ba2d2e64
commit
61bfc6fb5d
@ -306,13 +306,12 @@ public class TableInfo {
|
||||
* @return 字段列表
|
||||
*/
|
||||
public String[] obtainInsertColumns(Object entity, boolean ignoreNulls) {
|
||||
String[] defaultInsertColumns = ArrayUtil.concat(insertPrimaryKeys, columns);
|
||||
if (!ignoreNulls) {
|
||||
return defaultInsertColumns;
|
||||
return ArrayUtil.concat(insertPrimaryKeys, columns);
|
||||
} else {
|
||||
MetaObject metaObject = EntityMetaObject.forObject(entity, reflectorFactory);
|
||||
List<String> retColumns = new ArrayList<>();
|
||||
for (String insertColumn : defaultInsertColumns) {
|
||||
for (String insertColumn : columns) {
|
||||
if (onInsertColumns != null && onInsertColumns.containsKey(insertColumn)) {
|
||||
retColumns.add(insertColumn);
|
||||
} else {
|
||||
@ -323,7 +322,7 @@ public class TableInfo {
|
||||
retColumns.add(insertColumn);
|
||||
}
|
||||
}
|
||||
return retColumns.toArray(new String[0]);
|
||||
return ArrayUtil.concat(insertPrimaryKeys, retColumns.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -58,6 +58,13 @@ public class Entity04TestStarter {
|
||||
mapper.update(entity04);
|
||||
|
||||
|
||||
Entity04 entity05 = new Entity04();
|
||||
// entity05.setId("1");
|
||||
entity05.setAge(200);
|
||||
|
||||
mapper.insertSelective(entity05);
|
||||
|
||||
|
||||
List<Entity04> entity04s = mapper.selectAll();
|
||||
System.out.println(entity04s);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user