Cache Query Result in Spring JPA in ArrayList

Viewed 215

I have a query result in spring data Like :

public interface user extends extends CrudRepository<UserRegistration, Long> {
@Query(value="select ur from UserRegistration ur where "
        + " ur.location.id IN ?1 AND"
        + " ur.event.id IN ?2")
        public List<UserRegistration> getUsersBylocationAndEvent(long[] locationList, long[] eventList);
}

and use this method in service implementation as

public class userServiceImpl implements userService{
@Autowired
UserRegistrationRepository userRegistrationRepository;

@Override
public List<UserRegistration> getUserRegistarationByEventAndLocation(long[] locationList, long[] eventList, int checkInFlag, Date checkInDate, int checkOutFlag, Date checkOutDate) {
    List<UserRegistration> userRegistrationList = userRegistrationRepository.getUserRegByLocationIdsAndEvenIds(locationList, eventList);

    return userRegistrationList;
}}

And I used this method "getUserRegistarationByEventAndLocation()" in multiple webServices, so I want to cache the result when first webservice called in list and can use this list in other webService.

1 Answers
Related