mariiaKraievska opened a new pull request, #3854:
URL: https://github.com/apache/fineract/pull/3854

   ## Description
   
   JIRA ticket - https://issues.apache.org/jira/browse/FINERACT-2022
   
   In this PR, I implemented QueryDSL to generate code for type-safe SQL 
queries for the Account entity.
   I used QueryDSL for complex JPA queries, removed all custom "@Query" 
annotations from repository classes, and refused to use JdbcTemplate.
   
   I'd like to explain the reason for using the `@Transactional(propagation = 
Propagation.REQUIRES_NEW)` annotation for methods that use QueryDSL for 
"select" queries.
   
   Previously, using `JdbcTemplate` to work with the database, we did not catch 
errors related to optimistic locking. This was due to the fact that 
`JdbcTemplate` works directly with SQL and does not take into account the 
optimistic locking mechanisms built into JPA. But they were still present and 
it could be seen in the logs.
   
   After switching to QueryDSL, we started to face `OptimisticLockException` on 
read operations. This indicated that we had concurrent changes in the database 
and these changes were being checked at the time of the read requests, which 
are now performed via JPA. To avoid such cases and ensure data consistency, I 
applied the `REQUIRES_NEW` annotation. This allows each read request to be 
executed in a new transaction, isolating it from other operations that may be 
modifying the data at the same time.
   
   Please let me know if you have any questions or suggestions.
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request 
- thanks!
   
   - [ ] Write the commit message as per 
https://github.com/apache/fineract/#pull-requests
   
   - [ ] Acknowledge that we will not review PRs that are not passing the build 
_("green")_ - it is your responsibility to get a proposed PR to pass the build, 
not primarily the project's maintainers.
   
   - [ ] Create/update unit or integration tests for verifying the changes made.
   
   - [ ] Follow coding conventions at 
https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.
   
   - [ ] Add required Swagger annotation and update API documentation at 
fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with 
details of any API changes
   
   - [ ] Submission is not a "code dump".  (Large changes can be made "in 
repository" via a branch.  Ask on the developer mailing list for guidance, if 
required.)
   
   FYI our guidelines for code reviews are at 
https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.
   


-- 
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