title: org.hibernate.HibernateException: save is not valid without active transaction
body: <p>I am creating <code>JSF</code> application and using some hibernate stuff in it. All I want to do is to save the entity into the database but I keep getting this exception:</p>
  
  <pre><code>org.hibernate.HibernateException: save is not valid without active transaction
  </code></pre>
  
  <p>At first I was getting this exception:</p>
  
  <pre><code>org.hibernate.HibernateException: No CurrentSessionContext configured!
  </code></pre>
  
  <p>Then I found that I need to add this into my hibernate configuration:</p>
  
  <pre><code>&lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
  </code></pre>
  
  <p>This solved this issue but now the above one appears.
  I am saving entity into database like this:</p>
  
  <pre><code>public void create(T entity) {
      getSessionFactory().getCurrentSession().save(entity);
  }
  </code></pre>
  
  <p>My hibernate.cfg.xml file looks like this:</p>
  
  <pre><code>&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:3306/online_tests_management&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;root&lt;/property&gt;
          &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
          &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
  
          &lt;mapping class="com.groupgti.onlinetests.management.db.Service"/&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>I am using:</p>
  
  <ul>
  <li>Hibernate-4.1.4.Final</li>
  <li>JDK 1.6</li>
  <li>Tomcat 6</li>
  <li>JSF 2.0</li>
  <li>PrimeFaces 3.3.1</li>
  <li>MySql</li>
  </ul>
  
  <p>Does someone know where might be the problem?</p>