Skip to content

Add convenient method JpaRepository::clear as companion of flush #3471

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

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented May 11, 2024

Sometimes we need to clear persistence context, especially for writing unit tests. We need to inject EntityManager before this commit, it is a bit inconvenient.

@quaff quaff changed the title Add convenient method JpaRepository::clearas companion of flush Add convenient method JpaRepository::clear as companion of flush May 11, 2024
Sometimes we need to clear persistence context, especially for writing unit tests. We need to inject `EntityManager` before this commit, it is a bit inconvenient.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 11, 2024
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels May 13, 2024
@mp911de
Copy link
Member

mp911de commented May 13, 2024

We do not want to mirror EntityManager API on the repository. Exposing the flush method already clutters the repository API and we do not want to continue in that way. We suggest implementing a repository fragment for your convenience.

@mp911de mp911de closed this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants