protected List<? extends Map<String, Object>> executeUpdateQuery( Object obj, boolean keysGenerated) { SqlParameterSource updateParameterSource = new MapSqlParameterSource(); if (this.sqlParameterSourceFactory != null) { updateParameterSource = this.sqlParameterSourceFactory.createParameterSource(obj); } if (keysGenerated) { KeyHolder keyHolder = new GeneratedKeyHolder(); this.jdbcOperations.update(this.updateSql, updateParameterSource, keyHolder); return keyHolder.getKeyList(); } else { int updated = this.jdbcOperations.update(this.updateSql, updateParameterSource); LinkedCaseInsensitiveMap<Object> map = new LinkedCaseInsensitiveMap<Object>(); map.put("UPDATED", updated); return Collections.singletonList(map); } }
private StringBuffer makeCondition() { StringBuffer sb = new StringBuffer(); List<SysQueryFieldBO> list = conf.getFieldListByFieldType(QueryConf.FIELDTYPE_CONDITION); if (list == null || list.size() == 0) { return sb; } sb.append(" where 1=1"); SysQueryFieldBO bo; Object param; String operand; SysQueryFieldBO operandbo; StringBuffer buf; // 一条AND语句 StringBuffer subbuf; // 操作符及右边值的处理 for (int i = 0; i < list.size(); i++) { bo = list.get(i); param = pMap.get(bo.getId().getColalias()); buf = new StringBuffer(); buf.append(" and "); buf.append(tableAlias.get(bo.getTabname())); buf.append("."); buf.append(bo.getColrealname()); subbuf = new StringBuffer(); if (!StringUtil.isEmpty(param)) { // 外界传参 subbuf.append(makeParamByOpper(param, bo.getOpper())); } else { // 联表查询条件 operand = bo.getOperand(); if (!StringUtil.isEmpty(operand)) { operandbo = conf.getByColailas(operand); if (operandbo != null) { // 判断join方式 String left = "", right = ""; if (JOINWAY_LEFT.equals(bo.getJoinway())) { // 左连接,在等号右边的列右加“(+)"表示即使右边为空,左边依旧返回,参见SQL的使用说明 right = "(+)"; } else if (JOINWAY_RIGHT.equals(bo.getJoinway())) { left = "(+)"; } // full 或者不填表示全连接 subbuf.append(left); subbuf.append(bo.getOpper()); subbuf.append(tableAlias.get(operandbo.getTabname())); subbuf.append("."); subbuf.append(operandbo.getColrealname()); subbuf.append(right); } else if (operand.startsWith("#")) { // 默认值 subbuf.append(makeParamByOpper(operand.substring(1), bo.getOpper())); } } } buf.append(subbuf); if (subbuf.length() > 0) { sb.append(buf); } } log.debug("[" + sb + "]"); return sb; }