Use prepared statements instead of string concatenated SQL everywhere - WIP (FINERACT-854)

This commit is contained in:
Joseph Makara
2021-04-13 06:10:51 +08:00
committed by Petri Tuomola
parent f96fc7df39
commit 859ce5af62
3 changed files with 10 additions and 5 deletions
@@ -62,7 +62,7 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
sql += " order by c.id"; sql += " order by c.id";
final List<GlobalConfigurationPropertyData> globalConfiguration = this.jdbcTemplate.query(sql, this.rm, final List<GlobalConfigurationPropertyData> globalConfiguration = this.jdbcTemplate.query(sql, this.rm,
new Object[] { DataTableApiConstant.CATEGORY_PPI }); survey ? new Object[] { DataTableApiConstant.CATEGORY_PPI } : new Object[] {});
return new GlobalConfigurationData(globalConfiguration); return new GlobalConfigurationData(globalConfiguration);
} }
@@ -281,7 +281,7 @@ public class GenericDataServiceImpl implements GenericDataService {
final List<ResultsetColumnValueData> columnValues = new ArrayList<>(); final List<ResultsetColumnValueData> columnValues = new ArrayList<>();
if (codeId != null) { if (codeId != null) {
final String sql = "select v.id, v.code_value from m_code_value v where v.code_id =?" + " order by v.order_position, v.id"; final String sql = "select v.id, v.code_value from m_code_value v where v.code_id =? order by v.order_position, v.id";
final SqlRowSet rsValues = this.jdbcTemplate.queryForRowSet(sql, Integer.class, new Object[] { codeId }); final SqlRowSet rsValues = this.jdbcTemplate.queryForRowSet(sql, Integer.class, new Object[] { codeId });
rsValues.beforeFirst(); rsValues.beforeFirst();
while (rsValues.next()) { while (rsValues.next()) {
@@ -297,7 +297,7 @@ public class GenericDataServiceImpl implements GenericDataService {
private SqlRowSet getDatatableMetaData(final String datatable) { private SqlRowSet getDatatableMetaData(final String datatable) {
final String sql = "select COLUMN_NAME, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLUMN_KEY" final String sql = "select COLUMN_NAME, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLUMN_KEY"
+ " from INFORMATION_SCHEMA.COLUMNS " + " where TABLE_SCHEMA = schema() and TABLE_NAME = ?" + " order by ORDINAL_POSITION"; + " from INFORMATION_SCHEMA.COLUMNS " + " where TABLE_SCHEMA = schema() and TABLE_NAME = ? order by ORDINAL_POSITION";
final SqlRowSet columnDefinitions = this.jdbcTemplate.queryForRowSet(sql, String.class, new Object[] { datatable }); final SqlRowSet columnDefinitions = this.jdbcTemplate.queryForRowSet(sql, String.class, new Object[] { datatable });
if (columnDefinitions.next()) { if (columnDefinitions.next()) {
@@ -18,5 +18,10 @@
-- --
-- two tables added: ReportCategoryList and FullReportList (FINERACT-1306) -- two tables added: ReportCategoryList and FullReportList (FINERACT-1306)
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report)VALUES ("ReportCategoryList", 'Table', '(NULL)', '(NULL)', '(NULL)', 1, 1); INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report)
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report)VALUES ("FullReportList", 'Table', '(NULL)', '(NULL)', '(NULL)', 1, 1); SELECT "ReportCategoryList", 'Table', '(NULL)', '(NULL)', '(NULL)', 1, 1
ON DUPLICATE key UPDATE report_name = 'ReportCategoryList';
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report)
SELECT "FullReportList", 'Table', '(NULL)', '(NULL)', '(NULL)', 1, 1
ON DUPLICATE key UPDATE report_name = 'FullReportList';