-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
status: feedback-providedFeedback has been providedFeedback has been provided
Description
Hi Spring Team,
Environment
- Spring Boot version 3.5.4
- Using spring-boot-starter-data-jpa
- H2 in memory data base
Steps to reproduce
- Declare a
JpaRepository
for any entity likepublic interface AccountRepository implements JpaRepository<Account,Long>
- Declare
AccountRepository accountRepository
and let Springframework inject the repository. - Call
accountRepository.getReferenceById(id)
with an non-null id value which is not yet persisted.
Expected
As per Springs @Repository
abstraction, a IncorrectResultSizeDataAccessException
is thrown.
Actual
JPAs EntityNotFoundException
is thrown.
Comments
This breaks the abstraction of Springs @Repository
over the underlying persistence layer / data store.
Other methods in JpaRepository
convert from JPA specific exceptions into Springs DataAccessException
hierarchy. Example: the method save(null)
throws InvalidDataAccessApiUsageException
. Remark: the Javadoc for save(id)
is wrong: it says IllegalArgumentException
.
Best,
Oliver
Metadata
Metadata
Assignees
Labels
status: feedback-providedFeedback has been providedFeedback has been provided