Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ca.qc.bdeb.info.p58.starbuck.seriousentertainment.Application; import java.util.List; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.Session; /** * * @author Guillaume */ public class EmployeDAO { Session session = SessionBD.ouvrirSession(); public Employe trouverEmployeDuClient(int id) { Employe emp = null; try { Query query = session.createQuery("from Employe where ID_REPRESENTANT = :id "); query.setParameter("id", id); List<?> list = query.list(); emp = (Employe) list.get(0); session.getTransaction().commit(); } catch (HibernateException e) { session.getTransaction().rollback(); } return emp; } }