ca.qc.bdeb.info.p58.starbuck.seriousentertainment.Application.CommandeDAO.java Source code

Java tutorial

Introduction

Here is the source code for ca.qc.bdeb.info.p58.starbuck.seriousentertainment.Application.CommandeDAO.java

Source

/*
 * 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 CommandeDAO {

    Session session = SessionBD.ouvrirSession();

    public List<Commande> lireListeCommandes(int id) {
        List<Commande> list = null;
        try {
            Query query = session.createQuery("from Commande where ID_CLIENT = :id ");
            query.setParameter("id", id);
            list = query.list();
            session.getTransaction().commit();
        } catch (HibernateException e) {
            session.getTransaction().rollback();
        }
        return list;
    }
}