[ 
https://issues.apache.org/jira/browse/FINERACT-3062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18140323#comment-18140323
 ] 

Charukesh G R commented on FINERACT-3062:
-----------------------------------------

Hi, I would like to work on this one. I plan to replace the native SQL in 
AbstractLockingService with a typed QueryDSL query, check that it returns the 
same rows, and add a test for it. Could you please assign it to me? 

Thank you!

> Type safe query: [SQL 021] Find lock IDs by loan ID in 
> (AbstractLockingService:70)
> ----------------------------------------------------------------------------------
>
>                 Key: FINERACT-3062
>                 URL: https://issues.apache.org/jira/browse/FINERACT-3062
>             Project: Apache Fineract
>          Issue Type: Sub-task
>            Reporter: Aleksandar Vidakovic
>            Priority: Major
>              Labels: beginner, beginner-friendly, native-sql, 
> native-sql-entry-021, querydsl, sql-select, translation-generated
>
> *Entry 21* of the native SQL inventory \(SELECT, module fineract\-cob\).
> Source: 
> [AbstractLockingService.java#L70|https://github.com/apache/fineract/blob/0f677b99aa453ea5be4f2e0115562e85ad1db012/fineract-cob/src/main/java/org/apache/fineract/cob/domain/AbstractLockingService.java#L70]
> Status: Translation generated automatically; needs review and compilation.
> h3. Native SQL \(as built by the Java code\)
> {code:language=sql}
> SELECT loan_id
> FROM ${getTableName()}
> WHERE loan_id IN (${loanIds})
> {code}
> h3. Proposed QueryDSL translation
> {code:language=java}
> // imports
> import com.querydsl.core.types.dsl.PathBuilder;
> import com.querydsl.sql.SQLQueryFactory;
> import java.util.Collection;
> import java.util.List;
> // method parameters used below
> //   Collection<Long> loanIds   (was concatenated into the SQL: loanIds)
> // table name is only known at runtime (getTableName())
> PathBuilder<Object> dynTable = new PathBuilder<>(Object.class, 
> getTableName());
> List<Object> result = queryFactory.select(dynTable.getComparable("loan_id", 
> Comparable.class))
>     .from(dynTable)
>     .where(dynTable.getComparable("loan_id", Comparable.class).in(loanIds))
>     .fetch();
> {code}
> h3. Done when
> * QueryDSL version compiles against the generated Q\-types
> * Behaviour matches the native query \(same rows, same parameters\) on 
> MySQL/MariaDB and PostgreSQL
> * Existing tests pass, or a test covering the query was added
> * The native SQL string is removed



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to