@Override public Update<T> set(String property, Object value) { if (updateParam.getData() == null) updateParam.setData(new HashMap<>()); if (updateParam.getData() instanceof Map) { ((Map) updateParam.getData()).put(property, value); } else { try { BeanUtils.setProperty(updateParam.getData(), property, value); } catch (Exception e) { logger.warn("property error", e); } } return this; }
public Update<T, Q> set(String property, Object value) { if (param.getData() == null) { ((UpdateParam) param).setData(new HashMap<>()); } if (param.getData() instanceof Map) { ((Map) param.getData()).put(property, value); } else { try { propertyUtilsBean.setProperty(param.getData(), property, value); } catch (Exception e) { logger.warn("set property error", e); } } return this; }
public UpdateFromBean<T, Q> fromBean() { this.bean = param.getData(); return new UpdateFromBean<>(this); }
@Override public int exec() throws SQLException { boolean supportBefore = !triggerSkip && table.getMeta().triggerIsSupport(Trigger.update_before); boolean supportDone = !triggerSkip && table.getMeta().triggerIsSupport(Trigger.update_done); Map<String, Object> context = null; if (supportBefore || supportDone) { context = table.getDatabase().getTriggerContextRoot(); context.put("table", table); context.put("database", table.getDatabase()); context.put("param", updateParam); } if (supportBefore) { table.getMeta().on(Trigger.update_before, context); } SqlRender<UpdateParam> render = table.getMeta().getDatabaseMetaData().getRenderer(SqlRender.TYPE.UPDATE); SQL sql = render.render(table.getMeta(), updateParam); tryValidate(updateParam.getData(), Validator.Operation.UPDATE); int total = sqlExecutor.update(sql); if (supportDone) { context.put("total", total); table.getMeta().on(Trigger.update_done, context); } return total; }