-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JpaRepository.getOne/getById method name should indicate that it returns a reference #2232
Labels
type: enhancement
A general enhancement
Comments
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged
label
Jun 9, 2021
schauder
added
type: enhancement
A general enhancement
and removed
status: waiting-for-triage
An issue we've not yet triaged
labels
Jun 14, 2021
We agree with the proposed solution. |
gregturn
added a commit
that referenced
this issue
Jan 4, 2022
Introduce a repository method that makes it clear the return is a reference. Deprecate the previous methods. See #2232.
gregturn
added a commit
that referenced
this issue
Jan 4, 2022
Introduce a repository method that makes it clear the return is a reference. Deprecate the previous methods. See #2232.
gregturn
added a commit
that referenced
this issue
Jan 4, 2022
Introduce a repository method that makes it clear the return is a reference. Deprecate the previous methods. Closes #2232.
schauder
added a commit
that referenced
this issue
Jan 13, 2022
schauder
added a commit
that referenced
this issue
Jan 21, 2022
awood
added a commit
to RedHatInsights/rhsm-subscriptions
that referenced
this issue
Jun 1, 2022
Spring Data deprecated getById because it didn't do what people thought it did. Rather than fetching the entity, getById returned a JPA proxy object. The method has been replaced with the more accurately named getReferenceById. In the case of the code this commit patches, it appears that the original author wanted the semantics associated with findById and got tripped up by the confusing naming. See spring-projects/spring-data-jpa#2232
awood
added a commit
to RedHatInsights/rhsm-subscriptions
that referenced
this issue
Jun 1, 2022
Spring Data deprecated getById because it didn't do what people thought it did. Rather than fetching the entity, getById returned a JPA proxy object. The method has been replaced with the more accurately named getReferenceById. In the case of the code this commit patches, it appears that the original author wanted the semantics associated with findById and got tripped up by the confusing naming. See spring-projects/spring-data-jpa#2232
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JpaRepository methods getOne/getById methods are often used by accident by inexperienced developers instead of findById.
These methods call EntityManager::getReference and return a reference.
The method name should indicate that.
We should consider adding method JpaRepository::getReferenceById and deprecating getById (getOne is already deprecated).
The text was updated successfully, but these errors were encountered: