Skip to content
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

Qualified EntityManager/EntityManagerFactory injection (aligned with Jakarta Persistence 3.2) #33414

Open
hantsy opened this issue Aug 22, 2024 · 0 comments
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@hantsy
Copy link
Contributor

hantsy commented Aug 22, 2024

It is great that Spring 6.2 adds initial Jakarta Persistence 3.2 support.

Jakarta Persistence 3.2 brings CDI Inject support for EntityManager and EntityManagerFactory.

Spring should align with this change and add Inject/Autowired support for EntityManager and EntityManagerFactory

@Inject @BookstoreDB
EntityManager bookstoreEM;

@Inject @CustomersDB
EntityManager customersEM;

The @BookstoreDB and CustomersDB are meta-annotations with @Qulifier to identify different persistence unit/datasource. And allow developers to create the EMF factory bean with these qualifiers(1) or properties(2,3) to specify it.

@BookstoreDB // 1
@Bean 
public LocalContainerEntityManagerFactoryBean ...(){

    emf.setQulifierNames(array of string) // 2
    emf.setQulifierClasses(array of classes) // 3
}

By default, only one db data source, all qualifiers can be ignored.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 22, 2024
@jhoeller jhoeller added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Sep 9, 2024
@jhoeller jhoeller changed the title Support Inejct EntityManager and EMF Qualified EntityManager/EntityManagerFactory injection (aligned with Jakarta Persistence 3.2) Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

No branches or pull requests

3 participants