title: Hibernate criterial selection returns null
body: <p>Trying to make a criterial searching in a dabase using hibernate which returns null, here's the code</p>
  
  <pre><code>public interface DatabaseHandler&lt;T&gt; {
      public static SessionFactory DATABASE_SESSION = new MetadataSources(
          new StandardServiceRegistryBuilder().configure().build())
          .buildMetadata().buildSessionFactory();;
      public abstract T handle() throws NullPointerException;
      public abstract T whatToDo(Session session) throws NullPointerException;
  }
  
  public abstract class DatabaseOutput&lt;T&gt; implements DatabaseHandler&lt;T&gt;{
      @Override
      public T handle() throws NullPointerException{
          Session session = DatabaseHandler.DATABASE_SESSION.openSession();
              session.beginTransaction();
          T result = this.whatToDo(session);
          session.getTransaction().commit();
          session.close();
          return (result != null ? result : (T)(new Object()));
      }
  }
  </code></pre>
  
  <p>//----------------------------------------------------------------------------------------------------------------------------------</p>
  
  <pre><code>public class ListCellCategorie extends ListCell&lt;Categorie&gt;{
      // this next inside the constructor
  this.setOnMouseClicked(event -&gt; {
          DatabaseOutput&lt;List&lt;Produit&gt;&gt; giveMeInformations = new DatabaseOutput&lt;List&lt;Produit&gt;&gt;() {
              @Override
              public List&lt;Produit&gt; whatToDo(Session session) {
                  System.out.println(Title.getText());
                  List&lt;Produit&gt; maListe = session.createQuery("from InternalPackage.POO.Classes.Produit where Produit.categorieProduit = 'Chapeau'").list();
                  System.out.println(maListe);
                  return maListe;
              }
          };
          ControllersSupervisor.PRODUCTS_LIST.clear();
          ControllersSupervisor.PRODUCTS_LIST.addAll(giveMeInformations.handle());
      });
  }
  </code></pre>
  
  <p>Result:
  Chapeau // from the System.out.println(Title.getText());</p>
  
  <p>Error:</p>
  
  <pre><code>Chapeau
  Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
  at java.lang.String$CaseInsensitiveComparator.compare(String.java:1192)
  at java.lang.String$CaseInsensitiveComparator.compare(String.java:1186)
  at java.util.TreeMap.getEntryUsingComparator(TreeMap.java:376)
  at java.util.TreeMap.getEntry(TreeMap.java:345)
  at java.util.TreeMap.get(TreeMap.java:278)
  at org.hibernate.dialect.function.SQLFunctionRegistry.findSQLFunction(SQLFunctionRegistry.java:45)
  at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.findSQLFunction(SessionFactoryHelper.java:369)
  at org.hibernate.hql.internal.ast.tree.IdentNode.getDataType(IdentNode.java:374)
  at org.hibernate.hql.internal.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:652)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:5003)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1286)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4707)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4319)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2138)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:815)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:609)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:313)
  at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:261)
  at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:266)
  at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:189)
  at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:141)
  at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:115)
  at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:77)
  at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153)
  at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:546)
  at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:655)
  at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:102)
  at InternalPackage.UIComponents.Components.ListCellCategorie$1$1.whatToDo(ListCellCategorie.java:81)
  at InternalPackage.UIComponents.Components.ListCellCategorie$1$1.whatToDo(ListCellCategorie.java:77)
  at ExternalPackage.DataBaseIO.DatabaseOutput.handle(DatabaseOutput.java:13)
  at InternalPackage.UIComponents.Components.ListCellCategorie$1.handle(ListCellCategorie.java:87)
  at InternalPackage.UIComponents.Components.ListCellCategorie$1.handle(ListCellCategorie.java:74)
  at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
  at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
  at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
  at javafx.event.Event.fireEvent(Event.java:198)
  at javafx.scene.Node.fireEvent(Node.java:8413)
  at com.jfoenix.controls.JFXRippler.lambda$initListeners$5(JFXRippler.java:273)
  at com.jfoenix.controls.JFXRippler$$Lambda$6.handle(Unknown Source)
  at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
  at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
  at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
  at javafx.event.Event.fireEvent(Event.java:198)
  at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3470)
  at javafx.scene.Scene$ClickGenerator.access$8100(Scene.java:3398)
  at javafx.scene.Scene$MouseHandler.process(Scene.java:3766)
  at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
  at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
  at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
  at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
  at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
  at com.sun.glass.ui.View.notifyMouse(View.java:937)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
  at java.lang.Thread.run(Thread.java:748)
  </code></pre>