Skip to content

Circular dependency between AttributeConverter and JPA #41156

Closed as not planned
Closed as not planned
@TofanMihai

Description

@TofanMihai

Upon migrating to Jakarta EE and upgrading to Spring 3.0+, we've noticed that the EntityManagerFactory defined in HibernateJpaConfiguration is causing a circular dependency issue with our converters.

Specifically, any custom converter implementing the AttributeConverter interface can no longer have JPA repositories injected into it because they form a cyclic dependency.

┌─────┐
| entityManagerFactory defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
↑     ↓
| customConverter implementing jakarta.persistence.AttributeConverter<T,M>
↑     ↓
| xService defined in xProject
↑     ↓
| xRepository defined in xProject defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration
↑     ↓
| jpaSharedEM_entityManagerFactory
└─────┘

This issue can be encountered on any spring version > 3.0.0 which requires jakarta.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions