|
@@ -73,11 +73,7 @@ public class ServiceImpl<M extends BaseMapper<T, PK>, T, PK extends Serializable
|
|
TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
|
|
TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
|
|
if (null != tableInfo) {
|
|
if (null != tableInfo) {
|
|
try {
|
|
try {
|
|
- String keyProperty = tableInfo.getKeyProperty();
|
|
|
|
- if (keyProperty == null) {
|
|
|
|
- throw new MybatisPlusException("Error: Cannot execute. Could not find @TableId.");
|
|
|
|
- }
|
|
|
|
- Method m = cls.getMethod("get" + StringUtils.capitalize(keyProperty));
|
|
|
|
|
|
+ Method m = cls.getMethod("get" + StringUtils.capitalize(tableInfo.getKeyProperty()));
|
|
Object idVal = m.invoke(entity);
|
|
Object idVal = m.invoke(entity);
|
|
if (null != idVal) {
|
|
if (null != idVal) {
|
|
return selective ? updateSelectiveById(entity) : updateById(entity);
|
|
return selective ? updateSelectiveById(entity) : updateById(entity);
|
|
@@ -87,6 +83,8 @@ public class ServiceImpl<M extends BaseMapper<T, PK>, T, PK extends Serializable
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ throw new MybatisPlusException("Error: Cannot execute. Could not find @TableId.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|