具有学术好奇心。JIT能否接受这样的代码,识别出格式字符串是静态常量,并因此预计算切片格式字符串,从而将其优化为仅使用最小附加的StringBuilder?
public static String buildDeleteSql(BaseObject object)
{
String table;
String schema;
String deleteSql = String.format(
"DELETE FROM %s.%s WHERE %s = '%s' AND %s = '%s'",
schema,
table,
BaseObject.ATTR_ID,
StringUtils.escapeForSQLString(object.getId()),
BaseObject.ATTR_REVISION,
StringUtils.escapeForSQLString(object.getRevision())
);
return deleteSql;
}