PersistenceUnit vs PersistenceContext
PersistenceUnit injects an EntityManagerFactory, and PersistenceContext injects an EntityManager. It’s generally better to use PersistenceContext unless you really need to manage the EntityManager lifecycle manually.