I have an interface public interface IAllAccountsRepo extends CrudRepository
and a method in that like below
@Query(value = "SELECT * FROM account a where a.id in :id AND a.accountType = :accountType", nativeQuery=true)
public AccountEntity findByIdAndAccountType(@Param("id") String id, @Param("accountType") String accountType);
When i call this method in a helper class, where I will get a list of ids and I loop through them and pass in a filter value to the above method, but i have issues when there is no record matching the query in the database.
It just stops by saying null(when there is no record in db). I do not want to through exception, need to ignore and proceed if i can do that. Is there anyway i can code it to ignore the null and proceed? or do i need criteria query or any other?
for (String id : accountIdList) {
accountEntityTemp = iAllAccountsRepo.findByIdAndAccounttype(id, accounttype);
System.out.println("bs" + accountEntityTemp.getId());
if (accountEntityTemp != null) {
accountsEntityList.add(accountEntityTemp);
}
}
accountEntityTemp = null for one id and accounttype and i'm getting the below error.
2015-12-10 14:20:03.784 WARN 10524 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Handler execution resulted in exception: null
Thanks.