try {
IbatisSqlMapConfigParser ibatisSqlMapConfigParser = new IbatisSqlMapConfigParser();
String sqlString = ibatisSqlMapConfigParser.parse(op.getSql(),toMap(table.includeSqls));
String namedSql = SqlParseHelper.convert2NamedParametersSql(sqlString,":",""); // TODO 确认要删除本行?,因为与SqlFactory里面的代码重复
Sql sql = new SqlFactory().parseSql(namedSql);
sql.setSqlSegments(ibatisSqlMapConfigParser.getSqlSegments());
LinkedHashSet<SqlParameter> finalParameters = addExtraParams2SqlParams(op.getExtraparams(), sql);
sql.setParams(finalParameters);
sql.setColumns(processWithCustomColumns(getCustomColumns(table),sql.getColumns()));
String ibatisSql = getIbatisSql(op, sql);
sql.setIbatisSql(ibatisSql);
sql.setMybatisSql(sql.replaceWildcardWithColumnsSqlName(SqlParseHelper.convert2NamedParametersSql(op.getSql(),"#{","}")) + " "+op.getAppend()); // FIXME 修正ibatis3的问题
sql.setOperation(op.getName());
sql.setParameterClass(op.getParameterClass());
sql.setResultClass(op.getResultClass());
sql.setRemarks(op.getRemarks());
sql.setPaging(op.isPaging());
sql.setSqlmap(op.getSqlmap());
sql.setResultMap(op.getResultMap());
//FIXME 增加insert append="nowait"至 CDATA ]]>结尾的前面
if(StringHelper.isNotBlank(op.getMultiplicity())) {
sql.setMultiplicity(op.getMultiplicity());
}
//FIXME 与dalgen的规则是否一致
if(StringHelper.isNotBlank(op.getParamtype())) {
sql.setParamType(op.getParamtype());
}else if(StringHelper.isBlank(op.getParamtype()) && (sql.isSelectSql() || sql.isDeleteSql())) {
sql.setParamType(Sql.PARAMTYPE_PRIMITIVE);
}
sql.afterPropertiesSet();
return afterProcessed(sql,op,table);
}catch(Exception e) {
throw new RuntimeException("parse sql error on table:"+table.getSqlName()+" operation:"+op.getName()+"() sql:"+op.getSql(),e);
}
}