Answer the question
In order to leave comments, you need to log in
How to get the object correctly using Spring jdbc?
I get an error with this code, why can't I send a request?
Exception in thread "main" org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
if (object.getClass().equals(Company.class)) {
Company company = (Company) object;
String query = "SELECT COMPANY_ID FROM companies WHERE COMPANY_ID = ?";
return jdbcOperations.queryForObject(query, Long.class, company.getId());
}
Answer the question
In order to leave comments, you need to log in
Well, I understand that it is not fashionable to read the documentation, but the error itself clearly enough says what happened.
It is expected that the query will return exactly one value, and it returned 0. Check what you have there in the database.
Pull the request with your hands.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question