use of org.beetl.sql.core.SQLScript in project jSqlBox by drinkjava2.
the class BeetlSqlTempalte method doRender.
private static PreparedSQL doRender(SQLManager sm, String sqlId, Object paras) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("_root", paras);
SQLScript script = sm.getScript(sqlId);
SQLResult result = null;
try {
// run method in SQLScript is protected, have to make it accessible
Method method = SQLScript.class.getDeclaredMethod("run", Map.class);
ReflectionUtils.makeAccessible(method);
result = (SQLResult) method.invoke(script, param);
} catch (Exception e) {
throw new SqlBoxException("Can not access method 'run' in class 'org.beetl.sql.core.SQLScript'");
}
PreparedSQL sp = new PreparedSQL();
sp.setSql(result.jdbcSql);
List<SQLParameter> sqlparam = result.jdbcPara;
Object[] params = new Object[sqlparam.size()];
for (int i = 0; i < sqlparam.size(); i++) {
params[i] = sqlparam.get(i).value;
}
sp.setParams(params);
return sp;
}
Aggregations