title: Hibernate loading could not initialize proxy - no Session
body: <p>I'm trying to do a simple app with Spring and Hibernate. I am trying to select the list of articles in the database. the entites Articles and Fournisseurs. a fournisseur has a list of articles.
  it's a Maven project.
  The view will display the article list and Fournisseur list.</p>
  
  <p>i'm getting the following error:</p>
  
  <pre><code>    Hibernate: select fournisseu0_.ID_FOURNISSEUR as ID1_70_, fournisseu0_.NOM as NOM70_, fournisseu0_.TELEPHONE as TELEPHONE70_, fournisseu0_.DATE_AJOUT as DATE4_70_, fournisseu0_.DATE_MODIFICATION as DATE5_70_, fournisseu0_.id_adresse as id6_70_ from FOURNISSEURS fournisseu0_
  Hibernate: select adresse0_.ID_ADRESSE as ID1_66_1_, adresse0_.VILLE as VILLE66_1_, adresse0_.RUE as RUE66_1_, adresse0_.CODE_POSTAL as CODE4_66_1_, fournisseu1_.ID_FOURNISSEUR as ID1_70_0_, fournisseu1_.NOM as NOM70_0_, fournisseu1_.TELEPHONE as TELEPHONE70_0_, fournisseu1_.DATE_AJOUT as DATE4_70_0_, fournisseu1_.DATE_MODIFICATION as DATE5_70_0_, fournisseu1_.id_adresse as id6_70_0_ from ADRESSE adresse0_ left outer join FOURNISSEURS fournisseu1_ on adresse0_.ID_ADRESSE=fournisseu1_.ID_FOURNISSEUR where adresse0_.ID_ADRESSE=?
  Hibernate: select adresse0_.ID_ADRESSE as ID1_66_1_, adresse0_.VILLE as VILLE66_1_, adresse0_.RUE as RUE66_1_, adresse0_.CODE_POSTAL as CODE4_66_1_, fournisseu1_.ID_FOURNISSEUR as ID1_70_0_, fournisseu1_.NOM as NOM70_0_, fournisseu1_.TELEPHONE as TELEPHONE70_0_, fournisseu1_.DATE_AJOUT as DATE4_70_0_, fournisseu1_.DATE_MODIFICATION as DATE5_70_0_, fournisseu1_.id_adresse as id6_70_0_ from ADRESSE adresse0_ left outer join FOURNISSEURS fournisseu1_ on adresse0_.ID_ADRESSE=fournisseu1_.ID_FOURNISSEUR where adresse0_.ID_ADRESSE=?
  Hibernate: select adresse0_.ID_ADRESSE as ID1_66_1_, adresse0_.VILLE as VILLE66_1_, adresse0_.RUE as RUE66_1_, adresse0_.CODE_POSTAL as CODE4_66_1_, fournisseu1_.ID_FOURNISSEUR as ID1_70_0_, fournisseu1_.NOM as NOM70_0_, fournisseu1_.TELEPHONE as TELEPHONE70_0_, fournisseu1_.DATE_AJOUT as DATE4_70_0_, fournisseu1_.DATE_MODIFICATION as DATE5_70_0_, fournisseu1_.id_adresse as id6_70_0_ from ADRESSE adresse0_ left outer join FOURNISSEURS fournisseu1_ on adresse0_.ID_ADRESSE=fournisseu1_.ID_FOURNISSEUR where adresse0_.ID_ADRESSE=?
  Hibernate: select articles0_.ID_ARTICLE as ID1_67_, articles0_.TYPE_ARTICLE as TYPE2_67_, articles0_.NOMENCLATURE as NOMENCLA3_67_, articles0_.DESIGNATION as DESIGNAT4_67_, articles0_.UNITE as UNITE67_, articles0_.DESCRIPTION as DESCRIPT6_67_, articles0_.QUANTITE as QUANTITE67_, articles0_.SEUIL_MINIMUM as SEUIL8_67_, articles0_.DATE_AJOUT as DATE9_67_, articles0_.DATE_MODIFICATION as DATE10_67_, articles0_.FOURNISSEUR as FOURNIS11_67_ from ARTICLES articles0_
  ERROR: org.hibernate.LazyInitializationException - could not initialize proxy - no Session
  org.hibernate.LazyInitializationException: could not initialize proxy - no Session
      at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:167)
      at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
      at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
      at com.gest.stock.entities.Fournisseurs_$$_javassist_2.getNom(Fournisseurs_$$_javassist_2.java)
      at com.gest.stock.modele.FonctionDAO.update_table_article(FonctionDAO.java:159)
      at com.gest.stock.vue.VueAcceuilUtilisateur$2.actionPerformed(VueAcceuilUtilisateur.java:81)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
      at java.awt.Component.processMouseEvent(Component.java:6505)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
      at java.awt.Component.processEvent(Component.java:6270)
      at java.awt.Container.processEvent(Container.java:2229)
      at java.awt.Component.dispatchEventImpl(Component.java:4861)
      at java.awt.Container.dispatchEventImpl(Container.java:2287)
      at java.awt.Component.dispatchEvent(Component.java:4687)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
      at java.awt.Container.dispatchEventImpl(Container.java:2273)
      at java.awt.Window.dispatchEventImpl(Window.java:2719)
      at java.awt.Component.dispatchEvent(Component.java:4687)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703)
      at java.awt.EventQueue.access$000(EventQueue.java:102)
      at java.awt.EventQueue$3.run(EventQueue.java:662)
      at java.awt.EventQueue$3.run(EventQueue.java:660)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
      at java.awt.EventQueue$4.run(EventQueue.java:676)
      at java.awt.EventQueue$4.run(EventQueue.java:674)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
  Exception in thread "AWT-EventQueue-0" org.hibernate.LazyInitializationException: could not initialize proxy - no Session
      at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:167)
      at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
      at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
      at com.gest.stock.entities.Fournisseurs_$$_javassist_2.getNom(Fournisseurs_$$_javassist_2.java)
      at com.gest.stock.modele.FonctionDAO.update_table_article(FonctionDAO.java:159)
      at com.gest.stock.vue.VueAcceuilUtilisateur$2.actionPerformed(VueAcceuilUtilisateur.java:81)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
      at java.awt.Component.processMouseEvent(Component.java:6505)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
      at java.awt.Component.processEvent(Component.java:6270)
      at java.awt.Container.processEvent(Container.java:2229)
      at java.awt.Component.dispatchEventImpl(Component.java:4861)
      at java.awt.Container.dispatchEventImpl(Container.java:2287)
      at java.awt.Component.dispatchEvent(Component.java:4687)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
      at java.awt.Container.dispatchEventImpl(Container.java:2273)
      at java.awt.Window.dispatchEventImpl(Window.java:2719)
      at java.awt.Component.dispatchEvent(Component.java:4687)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703)
      at java.awt.EventQueue.access$000(EventQueue.java:102)
      at java.awt.EventQueue$3.run(EventQueue.java:662)
      at java.awt.EventQueue$3.run(EventQueue.java:660)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
      at java.awt.EventQueue$4.run(EventQueue.java:676)
      at java.awt.EventQueue$4.run(EventQueue.java:674)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
  </code></pre>
  
  <p>Articles.java: </p>
  
  <pre><code>    public class Articles implements Serializable {
  
      /**
       * 
       */
      private static final long serialVersionUID = 6066869813064596156L;
  
      private Long id_article;
      private String type_article;
      private String nomenclature;
      private String designation;
      private String unite;
      private String description;
      private Long quantite;
      private Long seuil_minimum;
      private Timestamp date_ajout;
      private Timestamp date_modification;
  
      @OneToMany(mappedBy = "articles")
      private Collection&lt;LignesCommandes&gt; lignesComandes;
  
      @ManyToOne
      private Fournisseurs fournisseur;
  
      public Articles() {
          super();
      }   
  
      public Articles(String type_article, String nomenclature,
              String designation, String unite, String description,
              Long quantite, Long seuil_minimum, Timestamp date_ajout,
              Timestamp date_modification) {
          super();
          this.type_article = type_article;
          this.nomenclature = nomenclature;
          this.designation = designation;
          this.unite = unite;
          this.description = description;
          this.quantite = quantite;
          this.seuil_minimum = seuil_minimum;
          this.date_ajout = date_ajout;
          this.date_modification = date_modification;
      }
  
      public Articles(Long id_article, String type_article, String nomenclature,
              String designation, String unite, String description,
              Long quantite, Long seuil_minimum,
              Fournisseurs fournisseur) {
          super();
          this.id_article = id_article;
          this.type_article = type_article;
          this.nomenclature = nomenclature;
          this.designation = designation;
          this.unite = unite;
          this.description = description;
          this.quantite = quantite;
          this.seuil_minimum = seuil_minimum;
          this.fournisseur = fournisseur;
      }
  
      public Articles(String type_article, String nomenclature,
              String designation, String unite, String description,
              Long quantite, Long seuil_minimum,
              Fournisseurs fournisseur) {
          super();
          this.type_article = type_article;
          this.nomenclature = nomenclature;
          this.designation = designation;
          this.unite = unite;
          this.description = description;
          this.quantite = quantite;
          this.seuil_minimum = seuil_minimum;
          this.fournisseur = fournisseur;
      }
  
      @Id
      @Column(name="id_article")
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      public Long getId_article() {
          return id_article;
      }
  
      public void setId_article(Long id_article) {
          this.id_article = id_article;
      }
  
      public String getType_article() {
          return type_article;
      }
  
      public void setType_article(String type_article) {
          this.type_article = type_article;
      }
  
      public String getNomenclature() {
          return this.nomenclature;
      }
  
      public void setNomenclature(String nomenclature) {
          this.nomenclature = nomenclature;
      }   
      public String getDesignation() {
          return this.designation;
      }
  
      public void setDesignation(String designation) {
          this.designation = designation;
      }   
      public String getUnite() {
          return this.unite;
      }
  
      public void setUnite(String unite) {
          this.unite = unite;
      }   
  
      public Date getDate_ajout() {
          return this.date_ajout;
      }
  
      public void setDate_ajout(Timestamp date_ajout) {
          this.date_ajout = date_ajout;
      }   
  
      public Timestamp getDate_modification() {
          return this.date_modification;
      }
  
      public void setDate_modification(Timestamp date_modification) {
          this.date_modification = date_modification;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public Long getQuantite() {
          return quantite;
      }
  
      public void setQuantite(Long quantite) {
          this.quantite = quantite;
      }
  
      public Collection&lt;LignesCommandes&gt; getLignesComandes() {
          return lignesComandes;
      }
  
      public void setLignesComandes(Collection&lt;LignesCommandes&gt; param) {
          this.lignesComandes = param;
      }
  
      public Fournisseurs getFournisseur() {
          return fournisseur;
      }
  
      public void setFournisseur(Fournisseurs param) {
          this.fournisseur = param;
      }
  
      public Long getSeuil_minimum() {
          return seuil_minimum;
      }
  
      public void setSeuil_minimum(Long seuil_minimum) {
          this.seuil_minimum = seuil_minimum;
      }
  }
  </code></pre>
  
  <p>Fournisseurs.java:</p>
  
  <pre><code>public class Fournisseurs implements Serializable {
  
  
  
      /**
       * 
       */
      private static final long serialVersionUID = 5404134101337003305L;
  
      private Long id_fournisseur;
      private String nom;
      private String telephone;
      private Timestamp date_ajout;
      private Timestamp date_modification;
      @OneToMany(mappedBy = "fournisseur")
      private Collection&lt;Articles&gt; articles;
      public Fournisseurs(Long id_fournisseur, String nom, String telephone,
              Timestamp date_ajout, Timestamp date_modification,
              Collection&lt;Articles&gt; articles, Adresse adresse) {
          super();
          this.id_fournisseur = id_fournisseur;
          this.nom = nom;
          this.telephone = telephone;
          this.date_ajout = date_ajout;
          this.date_modification = date_modification;
          this.articles = articles;
          this.adresse = adresse;
      }
  
      @OneToOne(mappedBy = "fournisseur")
      private Adresse adresse;
  
  
      public Timestamp getDate_ajout() {
          return date_ajout;
      }
  
      public void setDate_ajout(Timestamp date_ajout) {
          this.date_ajout = date_ajout;
      }
  
      public Timestamp getDate_modification() {
          return date_modification;
      }
  
      public void setDate_modification(Timestamp date_modification) {
          this.date_modification = date_modification;
      }
  
  
      public Fournisseurs() {
          super();
      }   
  
      public Fournisseurs(String nom, Adresse adresse, String telephone) {
          super();
          this.nom = nom;
          this.adresse = adresse;
          this.telephone = telephone;
      }
  
  
      public Fournisseurs(Long id_fournisseur, String nom,
              String telephone, Adresse adresse) {
          this.id_fournisseur = id_fournisseur;
          this.nom = nom;
          this.telephone = telephone;
          this.adresse = adresse;
      }
  
      @Id
      @Column(name="id_fournisseur")
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      public Long getId_fournisseur() {
          return this.id_fournisseur;
      }
  
      public void setId_fournisseur(Long id_fournisseur) {
          this.id_fournisseur = id_fournisseur;
      }   
      public String getNom() {
          return this.nom;
      }
  
      public void setNom(String nom) {
          this.nom = nom;
      }   
  
      public String getTelephone() {
          return this.telephone;
      }
  
      public void setTelephone(String telephone) {
          this.telephone = telephone;
      }
  
      public Collection&lt;Articles&gt; getArticles() {
          return articles;
      }
  
      public void setArticles(Collection&lt;Articles&gt; param) {
          this.articles = param;
      }
  
      public Adresse getAdresse() {
          return adresse;
      }
  
      public void setAdresse(Adresse adresse) {
          this.adresse = adresse;
      }
  }
  </code></pre>
  
  <p>ArticleDaoImpl.java:</p>
  
  <pre><code>    public class ArticleDaoImpl implements IArticleDao {
  
      public Long ajouterArticle(Articles article) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          session.save(article);
          session.beginTransaction().commit();
          return article.getId_article();
      }
  
      public void modifierArticle(Articles article) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          session.persist(article);
          session.beginTransaction().commit();
  
      }
  
      public void modifierArticleHQL(Articles article) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Query query = session.createQuery("update Articles a " +
                  "set a.type_article = ?1" +
                  ", a.nomenclature = ?2" +
                  ", a.designation = ?3" +
                  ", a.unite = ?4 " +
                  ", a.description = ?5 " +
                  ", a.quantite = ?6 " +
                  ", a.seuil_minimum = ?7 " +
                  ", a.date_modification = ?8 " +
                  " where a.id_article = ?9");
          query.setParameter("1", article.getType_article());
          query.setParameter("2", article.getNomenclature());
          query.setParameter("3", article.getDesignation());
          query.setParameter("4", article.getUnite());
          query.setParameter("5", article.getDescription());
          query.setParameter("6", article.getQuantite());
          query.setParameter("7", article.getSeuil_minimum());
          query.setParameter("8", article.getDate_modification());
          query.setParameter("9", article.getId_article());
          query.executeUpdate();
          session.beginTransaction().commit();
      }
  
      public void supprimerArticle(Long idArticle) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Articles materiel = (Articles) session.load(Articles.class, idArticle);
          session.delete(materiel);
          session.beginTransaction().commit();
      }
  
      public List&lt;Articles&gt; listArticles() {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          @SuppressWarnings("unchecked")
          List&lt;Articles&gt; result = session.createQuery("from Articles").list();
          session.getTransaction().commit();
          return result;
      }
  
      public List&lt;Articles&gt; listArticlesParFournisseur(Long idFournisseur) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Query query = session.createQuery("from Articles a where a.id_article = ?1");
          query.setParameter("1", idFournisseur);
          @SuppressWarnings("unchecked")
          List&lt;Articles&gt; articles = query.list();
          session.getTransaction().commit();
          return articles;
      }
  
      public Articles trouverArticleParId(Long idArticle) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          return (Articles) session.get(Articles.class, idArticle);
      }
  
      public Articles trouverArticleParNomenClature(String nomenclature) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Criteria criteria = session.createCriteria(Articles.class);
          criteria.add(Restrictions.eq("nomenclature", nomenclature));
          return (Articles) criteria.uniqueResult();
      }
  
      public Articles trouverArticleParDesignation(String designation) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Criteria criteria = session.createCriteria(Articles.class);
          criteria.add(Restrictions.like("designation", designation));
          return (Articles) criteria.uniqueResult();
      }
  
      public Articles trouverArticleParTypeArticle(String type_article) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Criteria criteria = session.createCriteria(Articles.class);
          criteria.add(Restrictions.eq("type_article", type_article));
          return (Articles) criteria.uniqueResult();
      }
  
      public Articles trouverArticleParDescription(String description) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Criteria criteria = session.createCriteria(Articles.class);
          criteria.add(Restrictions.like("description", description));
          return (Articles) criteria.uniqueResult();
      }
  
      @SuppressWarnings("unchecked")
      public List&lt;Articles&gt; listArticlesParQuantite(Long quantite) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Criteria criteria = session.createCriteria(Articles.class);
          criteria.add(Restrictions.ge("quantite", quantite));
          criteria.addOrder(Order.asc("id_article"));
          return (List&lt;Articles&gt;) criteria.list();
      }
  
      @SuppressWarnings("unchecked")
      public List&lt;Articles&gt; listArticlesParTypeArticle(String type_article) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Criteria criteria = session.createCriteria(Articles.class);
          criteria.add(Restrictions.eq("type_article", type_article));
          criteria.addOrder(Order.asc("id_article"));
          return (List&lt;Articles&gt;) criteria.list();
      }
  
      @SuppressWarnings("unchecked")
      @Override
      public List&lt;Object[]&gt; listArticlesEntreeSortie(String designation, Timestamp dateMin, Timestamp dateMax) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Criteria criteria = session.createCriteria(Articles.class, "articles");
          criteria.setFetchMode("entree",FetchMode.JOIN);
          criteria.setFetchMode("sortie",FetchMode.JOIN);
          criteria.add(Restrictions.like("designation", designation));
          criteria.add(Restrictions.gt("date_ajout", dateMin));
          criteria.add(Restrictions.le("date_ajout", dateMax));
          criteria.addOrder(Order.asc("id_article"));
          return (List&lt;Object[]&gt;) criteria.list();
      }
  
      @SuppressWarnings("unchecked")
      public List&lt;Object[]&gt; listArticlesEntreeSortie2(String designation, Timestamp dateMin, Timestamp dateMax) {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
          session.beginTransaction();
          Query query = session.createQuery("SELECT a, e, s FROM Articles as a, Entree as e, Sortie as s WHERE (a.id_article = e.id_article AND e.id_article = s.id_article AND a.designation =?1 AND e.dateAjout&gt;= ?2  AND e.dateAjout &lt;= ?3)");
          query.setParameter("1", designation);
          query.setParameter("2", dateMin);
          query.setParameter("3", dateMax);
          List&lt;Object[]&gt; results = query.list();
          return results;
      }
  }
  </code></pre>
  
  <p>VueArticle.java: </p>
  
  <pre><code>...
              btnArticle.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                   IFournisseurMetier metierFournisseur = (IFournisseurMetier) context.getBean("metierFournisseur");
                   List&lt;Fournisseurs&gt; fournisseurs = metierFournisseur.listFournisseurs();
                   DefaultListModel&lt;String&gt; listModel = new DefaultListModel&lt;String&gt;();
                   VueArticle.list_fournisseur.removeAll();
                   if(fournisseurs!=null){
                       for(Fournisseurs  fournisseur : fournisseurs){
                           if(fournisseur != null)
                           listModel.addElement(fournisseur.getNom());
                       }
                       VueArticle.list_fournisseur.setModel(listModel);
                   }
                   FonctionDAO fonctionDAO = new FonctionDAO();
                   fonctionDAO.update_table_article(VueArticle.tableArticle);
                   App.cl_conteneurPaneau.show(App.conteneurPaneau,"vueArticle");
              }
          });
  ...
  </code></pre>
  
  <p>FonctionDAO.java:</p>
  
  <pre><code>...
      public void update_table_article(JTable tableArticle) {
      IArticleMetier metierArticle = (IArticleMetier) context.getBean("metierArticle");
      List&lt;Articles&gt; articles = metierArticle.listArticles();
      String[] columnNames = {"Id article","Type article","Nomenclature","Designation","Description","Unite","Quantite","seuil min","Fournisseur","Date ajout","Date modification"};
      DefaultTableModel defaultTableModel = new DefaultTableModel();
      defaultTableModel.setColumnIdentifiers(columnNames);
      for(Articles article : articles){
            if(article!=null){
            Object[] object = new Object[columnNames.length];
            object[0]  = article.getId_article();
            object[1]  = article.getType_article();
            object[2]  = article.getNomenclature();
            object[3]  = article.getDesignation();
            object[4]  = article.getDescription();
            object[5]  = article.getUnite();
            object[6]  = article.getQuantite();
            object[7]  = article.getSeuil_minimum();
            object[8]  = article.getFournisseur().getNom();
            object[9]  = article.getDate_ajout();
            object[10] = article.getDate_modification();
            defaultTableModel.addRow(object);
            }
        }
      tableArticle.setModel(defaultTableModel);
      tableArticle.setPreferredScrollableViewportSize(new Dimension(1200, 70));
      tableArticle.setFillsViewportHeight(true);
      tableArticle.getColorModel().getRGB(226);
  
  }
  ...
  </code></pre>