default int insert(String sql, Object params) throws SQLException { return insert(new SimpleSQL(sql, params)); }
default int insert(String sql, Object params) throws SQLException { return insert(new SimpleSQL(sql, params)); }
@Override public int exec() throws SQLException { boolean supportBefore = !triggerSkip && table.getMeta().triggerIsSupport(Trigger.insert_before); boolean supportDone = !triggerSkip && table.getMeta().triggerIsSupport(Trigger.insert_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", insertParam); } if (supportBefore) { table.getMeta().on(Trigger.insert_before, context); } SqlRender<InsertParam> render = table.getMeta().getDatabaseMetaData().getRenderer(SqlRender.TYPE.INSERT); SQL sql = render.render(table.getMeta(), insertParam); tryValidate(insertParam.getData(), Validator.Operation.INSERT); int total = sqlExecutor.insert(sql); if (supportDone) { context.put("total", total); table.getMeta().on(Trigger.insert_done, context); } return total; }
@Override public int exec() throws SQLException { boolean supportBefore = !triggerSkip && table.getMeta().triggerIsSupport(Trigger.insert_before); boolean supportDone = !triggerSkip && table.getMeta().triggerIsSupport(Trigger.insert_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", insertParam); } if (supportBefore) { table.getMeta().on(Trigger.insert_before, context); } SqlRender<InsertParam> render = table.getMeta().getDatabaseMetaData().getRenderer(SqlRender.TYPE.INSERT); SQL sql = render.render(table.getMeta(), insertParam); tryValidate(insertParam.getData(), Validator.Operation.INSERT); int total = sqlExecutor.insert(sql); if (supportDone) { context.put("total", total); table.getMeta().on(Trigger.insert_done, context); } return total; }