package DAO;


import jakarta.persistence.EntityTransaction;
import jakarta.persistence.Query;
import metier.Session;

import java.util.List;

public class SessionDAO extends AbstractJpaDao<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;
        }
    }
}
