This is a code snippet of my project. Here I'm trying to get paginated data using Spring Data JPA. The pagination part works fine. However when searchParameter is NULL then I just want to return empty create a blank page in my UI
public Page<AccessLog> getDataInRange(long fromTime, long toTime, String searchParameter, Integer start,
Integer length) {
Page<AccessLog> accessPage;
if (searchParameter != null) {
accessPage = accessRepository.findBySystemTimestampBetween(fromTime, toTime,
new PageRequest(start, length));
} else
accessPage = null;
return accessPage;
}
However, this give an error when search parameter is null
Exception during execution of SpringSecurity application java.lang.NullPointerException: null
which caused because of that "null" value set as accessLogPage.
Any ideas?