title: How to get all rows from DB using hibernate?
body: <p>This code works fine, returning single row:</p>
  
  <pre><code>public static Customer GetCustomerFromDB() {
  
      Configuration configuration = new Configuration();
      configuration.configure("hibernate.cfg.xml");
      configuration.addAnnotatedClass(com.english.Customer.class);
      configuration.configure();
  
      ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
      SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
  
      Session session = sessionFactory.openSession();
      session.beginTransaction();
  
      Customer customer = session.get(Customer.class, 1);
  
      session.getTransaction().commit();
      session.close();
  
      sessionFactory.close();
      return customer;
  }
  </code></pre>
  
  <p>I need all rows from DB, from table customer. Table customer contains one element. Small change. Remove session.get() and add these lines:</p>
  
  <pre><code>//same code as above
  CriteriaQuery&lt;Customer&gt; criteriaQuery = session.getCriteriaBuilder().createQuery(Customer.class);
  criteriaQuery.from(Customer.class);
  
  List&lt;Customer&gt; contacts = session.createQuery(criteriaQuery).getResultList();
  Customer customer = contacts.get(0);
  //same code
  </code></pre>
  
  <p>Error:
  java.lang.NoClassDefFoundError: antlr/RecognitionException</p>
  
  <p>POM:</p>
  
  <pre><code>//...
          &lt;!-- https://mvnrepository.com/artifact/antlr/antlr --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;antlr&lt;/groupId&gt;
              &lt;artifactId&gt;antlr&lt;/artifactId&gt;
              &lt;version&gt;3.0ea8&lt;/version&gt;
          &lt;/dependency&gt;
  //...
  </code></pre>