FINERACT-984-7: Explicit ordering fix for moving ResultSets

This commit is contained in:
Arnold Galovics
2022-02-23 20:55:13 +01:00
committed by Aleksandar Vidakovic
parent 0c01e0c844
commit aa24599244
4 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ jobs:
sudo apt-get install ghostscript -y sudo apt-get install ghostscript -y
- name: Basic Auth Build & Test - name: Basic Auth Build & Test
run: ./gradlew --no-daemon -q --console=plain licenseMain licenseTest check build test --fail-fast doc -x :twofactor-tests:test -x :oauth2-test:test -PdbType=postgresql -PexcludeTests=org.apache.fineract.integrationtests.guarantor.GuarantorTest.testGuarantor_UNDO_DISBURSAL run: ./gradlew --no-daemon -q --console=plain licenseMain licenseTest check build test --fail-fast doc -x :twofactor-tests:test -x :oauth2-test:test -PdbType=postgresql
- name: 2FA Build & Test - name: 2FA Build & Test
run: ./gradlew --no-daemon -q --console=plain :twofactor-tests:test --fail-fast -PdbType=postgresql run: ./gradlew --no-daemon -q --console=plain :twofactor-tests:test --fail-fast -PdbType=postgresql
@@ -104,7 +104,7 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
sql.append("END"); sql.append("END");
return this.jdbcTemplate.query( return this.jdbcTemplate.query(
con -> con.prepareStatement(sql.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE), con -> con.prepareStatement(sql.toString(), ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE),
ps -> ps.setLong(1, productId), this.chartExtractor); ps -> ps.setLong(1, productId), this.chartExtractor);
} }
@@ -48,8 +48,10 @@ import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service @Service
@Transactional(readOnly = true)
public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformService { public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
@@ -76,7 +78,7 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
public List<GuarantorData> retrieveGuarantorsForLoan(final Long loanId) { public List<GuarantorData> retrieveGuarantorsForLoan(final Long loanId) {
final GuarantorMapper rm = new GuarantorMapper(); final GuarantorMapper rm = new GuarantorMapper();
String sql = "select " + rm.schema(); String sql = "select " + rm.schema();
sql += " where loan_id = ? group by g.id,gfd.id, gt.id, sa.id, oht.id, cv.id"; sql += " where loan_id = ? group by g.id,gfd.id, gt.id, sa.id, oht.id, cv.id order by g.id";
String finalSql = sql; String finalSql = sql;
final List<GuarantorData> guarantorDatas = this.jdbcTemplate.query(con -> { final List<GuarantorData> guarantorDatas = this.jdbcTemplate.query(con -> {
PreparedStatement preparedStatement = con.prepareStatement(finalSql, ResultSet.TYPE_SCROLL_SENSITIVE, PreparedStatement preparedStatement = con.prepareStatement(finalSql, ResultSet.TYPE_SCROLL_SENSITIVE,
@@ -98,7 +100,7 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
public GuarantorData retrieveGuarantor(final Long loanId, final Long guarantorId) { public GuarantorData retrieveGuarantor(final Long loanId, final Long guarantorId) {
final GuarantorMapper rm = new GuarantorMapper(); final GuarantorMapper rm = new GuarantorMapper();
String sql = "select " + rm.schema(); String sql = "select " + rm.schema();
sql += " where g.loan_id = ? and g.id = ? group by g.id, gfd.id, gt.id, sa.id, oht.id, cv.id"; sql += " where g.loan_id = ? and g.id = ? group by g.id, gfd.id, gt.id, sa.id, oht.id, cv.id order by g.id";
String finalSql = sql; String finalSql = sql;
final GuarantorData guarantorData = this.jdbcTemplate.query(con -> { final GuarantorData guarantorData = this.jdbcTemplate.query(con -> {
PreparedStatement preparedStatement = con.prepareStatement(finalSql, ResultSet.TYPE_SCROLL_SENSITIVE, PreparedStatement preparedStatement = con.prepareStatement(finalSql, ResultSet.TYPE_SCROLL_SENSITIVE,
@@ -233,10 +233,11 @@ public class ShareAccountReadPlatformServiceImpl implements ShareAccountReadPlat
sb.append(" and sa.status_enum = ? "); sb.append(" and sa.status_enum = ? ");
} }
sb.append(" and saps.status_enum = ?"); sb.append(" and saps.status_enum = ?");
sb.append(" order by sa.id");
params.add(PurchasedSharesStatusType.APPROVED.getValue()); params.add(PurchasedSharesStatusType.APPROVED.getValue());
Object[] whereClauseItems = params.toArray(); Object[] whereClauseItems = params.toArray();
return this.jdbcTemplate.query(con -> { return this.jdbcTemplate.query(con -> {
PreparedStatement preparedStatement = con.prepareStatement(sb.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, PreparedStatement preparedStatement = con.prepareStatement(sb.toString(), ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE); ResultSet.CONCUR_UPDATABLE);
for (int i = 0; i < whereClauseItems.length; i++) { for (int i = 0; i < whereClauseItems.length; i++) {
preparedStatement.setObject(i + 1, whereClauseItems[i]); preparedStatement.setObject(i + 1, whereClauseItems[i]);