@Spring: I wrote a Dao which find a id by another id. when it get the data its fine but when not found shows an exception such like this.
org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
Here is the dao:
public Integer getIdByMerchantId(Integer merchantId) {
String query = "SELECT id FROM transaction_history WHERE merchant_id=? ";
try {
return serviceJdbcTemplate.queryForObject(query, new Object[]{merchantId}, Integer.class);
} catch (EmptyResultDataAccessException e) {
log.error("Following query execution failed: ");
log.error(Utils.getLoggerFriendlyQuery(query), merchantId);
log.error("{} failed for merchant id {}. Error: {}", query, merchantId, e.getLocalizedMessage());
return null;
}
}