Skip to content

Commit

Permalink
chore: Close EntityManager on application shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mthmulders committed Jan 7, 2025
1 parent 6e0fc3c commit 4e98007
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.mulders.traqqr.jpa;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Disposes;
import jakarta.enterprise.inject.Produces;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
Expand All @@ -15,4 +16,8 @@ public class EntityManagerProducer {
public EntityManager createEntityManager() {
return emf.createEntityManager();
}

public void destroy(@Disposes EntityManager em) {
em.close();
}
}

0 comments on commit 4e98007

Please sign in to comment.