use of jodd.db.oom.sqlgen.ParsedSql in project jodd by oblac.
the class DbQueryBuilder method createAndPopulateDbQuery.
/**
* Prepares <code>DbQuery</code>.
*/
public DbOomQuery createAndPopulateDbQuery(ProxyTargetInfo proxyTargetInfo, String query) {
if (query == null) {
query = resolveQuery(proxyTargetInfo);
if (query == null) {
throw new DbOomException("Query not resolved.");
}
}
// sql generator
DbSqlGenerator dbSqlGenerator = parsedSqlMap.get(query);
if (dbSqlGenerator == null) {
ParsedSql parsedSql = sql(query).parse();
parsedSqlMap.put(query, parsedSql);
dbSqlGenerator = parsedSql;
}
// db oom query
DbOomQuery dbOomQuery = query(dbSqlGenerator);
// parameter names
String keyName = proxyTargetInfo.targetClass.getName() + "." + proxyTargetInfo.targetMethodName;
String[] paramNames = methodParamNames.get(keyName);
if (paramNames == null) {
paramNames = resolveMethodParameterNames(proxyTargetInfo);
methodParamNames.put(keyName, paramNames);
}
for (int i = 0; i < paramNames.length; i++) {
String paramName = paramNames[i];
dbOomQuery.setObject(paramName, proxyTargetInfo.arguments[i]);
}
return dbOomQuery;
}
Aggregations