This commit is contained in:
tuanvu
2025-09-17 15:32:50 +02:00
parent 90d30634d7
commit d47024314a
9 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
package DAO;
public class ChoixDAO {
}

View File

@@ -0,0 +1,4 @@
package DAO;
public class QuestionDAO {
}

View File

@@ -0,0 +1,4 @@
package DAO;
public class QuizzDAO {
}

View File

@@ -0,0 +1,5 @@
package DAO;
public class ReponseCourteDAO {
}

View File

@@ -0,0 +1,4 @@
package DAO;
public class ReponseDAO {
}

View File

@@ -0,0 +1,4 @@
package DAO;
public class SessionDAO {
}

View File

@@ -0,0 +1,14 @@
package DAO;
import java.io.Serializable;
import java.util.List;
public interface Tous<T, Id extends Serializable> {
T create(T t);
T update(T t);
T read(Id id);
void delete(T t);
List<T> findAll();
T save(T t);
}

View File

@@ -0,0 +1,31 @@
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<T, Id extends Serializable> implements Tous<T, Id> {
protected EntityManager em;
private Class<T> 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());
}
}
}

View File

@@ -0,0 +1,4 @@
package DAO;
public class UtilisateurDAO {
}