galovics commented on a change in pull request #2025:
URL: https://github.com/apache/fineract/pull/2025#discussion_r801407604



##########
File path: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java
##########
@@ -230,6 +246,495 @@ public SavingsAccountData retrieveOne(final Long 
accountId) {
         }
     }
 
+    @Override
+    public List<SavingsAccountTransactionData> 
retrieveAllTransactionData(final List<String> refNo) throws DataAccessException 
{
+        String inSql = String.join(",", Collections.nCopies(refNo.size(), 
"?"));
+        String sql = "select " + 
this.savingsAccountTransactionsForBatchMapper.schema() + " where tr.ref_no in 
(%s)";
+        Object[] params = new Object[refNo.size()];
+        int i = 0;
+        for (String element : refNo) {
+            params[i] = element;
+            i++;
+        }
+        return this.jdbcTemplate.query(String.format(sql, inSql), 
this.savingsAccountTransactionsForBatchMapper, params);
+    }
+
+    @Override
+    public List<SavingsAccountData> 
retrieveAllSavingsDataForInterestPosting(final boolean 
backdatedTxnsAllowedTill, final int pageSize,
+            final Integer status, final Long maxSavingsId) {
+        LocalDate currentDate = DateUtils.getLocalDateOfTenant().minusDays(1);
+
+        String sql = "select " + 
this.savingAccountMapperForInterestPosting.schema()
+                + "join (select a.id from m_savings_account a where a.id > ? 
and a.status_enum = ? limit ?) b on b.id = sa.id ";
+        if (backdatedTxnsAllowedTill) {
+            sql = sql
+                    + "where if (sa.interest_posted_till_date is not null, 
tr.transaction_date >= sa.interest_posted_till_date, tr.transaction_date >= 
sa.activatedon_date) ";
+        }
+
+        sql = sql + "and apm.product_type=2 and sa.interest_posted_till_date<" 
+ java.sql.Date.valueOf(currentDate);
+        sql = sql + " order by sa.id, tr.transaction_date, tr.created_date, 
tr.id";

Review comment:
       @fynmanoj I'm not saying this isn't the right way to go but I feel like 
whenever we rely on native SQL, there's a potential something is going to break 
easier than it should.
   The question I had was not really about using JPA entities to execute this 
operation because I understand that might be costly but rather to use JPQL 
(Java Persistence Query Language) to execute this query which is one level 
safer from a maintenance point of view than a native SQL.
   Thoughts?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to