budaidev commented on code in PR #4570:
URL: https://github.com/apache/fineract/pull/4570#discussion_r2056005675
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarInstanceRepository.java:
##########
@@ -45,24 +53,56 @@ public interface CalendarInstanceRepository extends
JpaRepository<CalendarInstan
* {@link CalendarType}
* @return
*/
+ @Cacheable(key = "T(java.util.Objects).hash(#entityId, #entityTypeId,
#calendarTypeId)")
CalendarInstance findByEntityIdAndEntityTypeIdAndCalendarTypeId(Long
entityId, Integer entityTypeId, Integer calendarTypeId);
+ @Cacheable(key = "T(java.util.Objects).hash(#entityId, #entityTypeId)")
@Query("select ci from CalendarInstance ci where ci.entityId = :entityId
and ci.entityTypeId = :entityTypeId")
CalendarInstance findCalendarInstaneByEntityId(@Param("entityId") Long
entityId, @Param("entityTypeId") Integer entityTypeId);
+ @Cacheable(key = "T(java.util.Objects).hash(#calendarId, #entityTypeId)")
Collection<CalendarInstance> findByCalendarIdAndEntityTypeId(Long
calendarId, Integer entityTypeId);
/** Should use in clause, can I do it without creating a new class? **/
+ @Cacheable(key = "T(java.util.Objects).hash(#groupId, #clientId,
#loanStatuses)")
@Query("select ci from CalendarInstance ci where ci.entityId in (select
loan.id from Loan loan where loan.client.id = :clientId and loan.group.id =
:groupId and loan.loanStatus in :loanStatuses) and ci.entityTypeId = 3")
List<CalendarInstance>
findCalendarInstancesForLoansByGroupIdAndClientIdAndStatuses(@Param("groupId")
Long groupId,
@Param("clientId") Long clientId, @Param("loanStatuses")
Collection<LoanStatus> loanStatuses);
/**
* EntityType = 3 is for loan
*/
-
+ @Cacheable(key = "T(java.util.Objects).hash(#calendarId, #loanStatuses)")
@Query("SELECT COUNT(ci.id) FROM CalendarInstance ci, Loan loan WHERE
loan.id = ci.entityId AND ci.entityTypeId = 3 AND ci.calendar.id = :calendarId
AND loan.loanStatus IN :loanStatuses ")
Integer countOfLoansSyncedWithCalendar(@Param("calendarId") Long
calendarId,
@Param("loanStatuses") Collection<LoanStatus> loanStatuses);
+ // Override JpaRepository methods to add cache eviction
+ @Override
+ @CacheEvict(allEntries = true)
+ <S extends CalendarInstance> S save(S entity);
Review Comment:
I added a saveAndFlush method with @CacheEvict annotation
--
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]