/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ package com.megatim.fdxconvert.dao; import com.megatim.fdxconvert.model.Tache; import com.megatim.fdxconvert.model.TypeFichier; import java.util.List; import java.util.Optional; import org.hibernate.Session; import org.hibernate.query.Query; /** * * @author STEPHANIE */ public class TacheDAO { private TacheDAO() { } public static Optional getTacheByLibelle(String libelle) { try ( Session session = HibernateUtil.getSessionFactory().openSession()) { Query query = session.createQuery("select t from Tache t where t.libelle = :libelle"); query.setParameter("libelle", libelle); return query.uniqueResultOptional(); } } public static List getTacheByTypeFichier(TypeFichier typeFichier) { try ( Session session = HibernateUtil.getSessionFactory().openSession()) { Query query = session.createQuery("select t from Tache t where t.typeFichier.code = :codeTypeFichier"); query.setParameter("codeTypeFichier", typeFichier.getCode()); return query.getResultList(); } } }