update DAO with theme
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package DAO;
|
||||
|
||||
import jakarta.persistence.EntityTransaction;
|
||||
import metier.Quizz;
|
||||
|
||||
public class QuizzDAO extends GenericDAOImpl<Integer, Quizz>{
|
||||
@@ -7,4 +8,11 @@ public class QuizzDAO extends GenericDAOImpl<Integer, Quizz>{
|
||||
super();
|
||||
this.setClass(Quizz.class);
|
||||
}
|
||||
|
||||
public void deleteAllQuiz(){
|
||||
EntityTransaction et= em.getTransaction();
|
||||
et.begin();
|
||||
em.createQuery("delete from Quizz").executeUpdate();
|
||||
et.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,29 @@
|
||||
package DAO;
|
||||
|
||||
|
||||
import jakarta.persistence.EntityTransaction;
|
||||
import jakarta.persistence.Query;
|
||||
import metier.Session;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SessionDAO extends GenericDAOImpl<Integer, Session> {
|
||||
public SessionDAO() {
|
||||
super();
|
||||
this.setClass(Session.class);
|
||||
}
|
||||
|
||||
public List<Session> findByTheme(String theme){
|
||||
EntityTransaction t=em.getTransaction();
|
||||
t.begin();
|
||||
Query query=em.createQuery("select s from Session s where s.theme=:theme");
|
||||
query.setParameter("theme",theme);
|
||||
List<Session> sessions=query.getResultList();
|
||||
t.commit();
|
||||
if(sessions.size()>0){
|
||||
return sessions;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public class Session implements Serializable {
|
||||
private int codePIN;
|
||||
private ArrayList<Quizz> quizzs;
|
||||
private ArrayList<Utilisateur> utilisateurs;
|
||||
private String theme;
|
||||
|
||||
public Session(){
|
||||
}
|
||||
@@ -41,4 +42,12 @@ public class Session implements Serializable {
|
||||
public ArrayList<Utilisateur> getUtilisateurs() {
|
||||
return this.utilisateurs;
|
||||
}
|
||||
|
||||
private String getTheme(){
|
||||
return this.theme;
|
||||
}
|
||||
|
||||
private void setTheme(String theme){
|
||||
this.theme = theme;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user