title: java.lang.NoSuchMethodError when closing Hibernate Session in Java Swing application
body: <p>I am getting this error:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.hibernate.Session.close()Ljava/sql/Connection;
  </code></pre>
  
  <p>When calling this function:</p>
  
  <pre><code>private static SessionFactory factory;
  
  public static void insert(Object model) {
  
      factory = new Configuration().configure().buildSessionFactory();
      Session session = factory.openSession();
      Transaction tx = session.beginTransaction();
  
      try {
  
          session.save(model);
          tx.commit();
  
      } catch (HibernateException exc) {
          if (tx != null)
              tx.rollback();
          exc.printStackTrace();
      } finally {
          session.close(); // here is when the error occurs
      }
  }
  </code></pre>
  
  <p>I believe I have imported all the necessary jars from <code>/lib/required/</code> directory in the latest Hibernate 5.0.1.</p>
  
  <p>The <code>hibernate.cfx.xml</code> file is also correctly configured:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
          &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
          &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3307/test&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt;
          &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
          &lt;property name="hibernate.query.factory_class"&gt;org.hibernate.hql.classic.ClassicQueryTranslatorFactory&lt;/property &gt;
  
          &lt;mapping  resource="customer.hbm.xml"/&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>And <code>customer.hbm.xml</code> mapping file:</p>
  
  <p>
  </p>
  
  <p></p>
  
  <pre><code>&lt;class name="com.test.app.model.Customer" table="customer"&gt;
  
      &lt;meta attribute="class-description"&gt;
          Test.
      &lt;/meta&gt;
  
      &lt;id column="id" name="id" type="int"&gt;
          &lt;generator class="native"/&gt;
      &lt;/id&gt;
  
      &lt;property name="name"           column="name"               type="string"/&gt;
      &lt;property name="phoneNumbers"   column="phone_numbers"      type="string"/&gt;
      &lt;property name="emailAddresses" column="email_addresses"    type="string"/&gt;
      &lt;property name="address"        column="address"            type="string"/&gt;
      &lt;property name="note"           column="note"               type="string"/&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p></p>
  
  <p>What could be the issue?</p>