package DAO; import jakarta.persistence.EntityManager; import jakarta.persistence.EntityTransaction; import jakarta.persistence.PersistenceException; import jpa.EntityManagerHelper; import java.io.Serializable; public abstract class TousDAOImpl implements Tous { protected EntityManager em; private Class entityClass; public TousDAOImpl() { this.em = EntityManagerHelper.getEntityManager(); } @Override public T save(T t) { EntityTransaction tx = em.getTransaction(); try { tx.begin(); em.persist(t); tx.commit(); return t; } catch (PersistenceException e) { throw new PersistenceException(e.getMessage()); } } }