-
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
Inject Repository into Custom Repository instance cause circular reference #3320
Comments
You cannot inject a repository facade into its own repository fragment as this creates a circular dependency. You could make the repository |
As I know, In Spring, using In summary your answer, if the Spring Data JPA interface is named BoardRepository, creating an Impl instance containing this name (ex: BoardRepositoryImpl) may result in a circular reference issue? @mp911de Upon referring to the official Spring Data JPA documentation, it is confirmed that a If it is not inconvenient, could you provide additional explanation or example? I realized myself. In official documents, did not use the Spring Data JPA interface to process CRUD where used it as an implementation, but instead used the EntityManager. In my situation, on the other hand, I referred to the Spring Data JPA interface where I used it as an implementation of Spring Data JPA. I realized that the basic strategy of the Spring Data JPA implementation would eventually lead to a self-reference, which would result in a reference to my own interface. I was able to find out by myself, but I'm sorry for the issue. |
First, I checked about two issue: #2384 , and this.
but I solve this problem by another way, I don't know why this way solved problem.
could I know Spring data JPA internal principle?
this is my example code.
With:
Error:
My Solution:
Instead use
boardJpaRepositoryImpl
, useboardRepositoryImpl
(orjpaBoardRepositoryImpl
). it worked to solve problem.(I wanted to create repository implementations, both with and without using JPA. That's why I didn't use the name BoardRepositoryImpl. Instead, I intended to use BoardJpaRepositoryImpl to signify an implementation using JPA. I'm curious if there are any rules against using the combination of a Spring Data JPA interface and its corresponding
impl
class in situations like this.)additionally, I tried to search spring data jpa documentation, and I knew about
repositoryImplementationPostfix
. Is there any connection with this?thanks to check this issue, and I apologize if this problem too much similar previous issues.
The text was updated successfully, but these errors were encountered: