Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Closing the entire session factory <code>mHibernateSessionFactory.close()</code> in your DAO code is an obvious no-go.</p> <p>Also you can't access mSession after the factory has been closed, it is stated in the java docs.</p> <p><code>void org.hibernate.SessionFactory.close() throws HibernateException</code></p> <blockquote> <p>Destroy this SessionFactory and release all resources (caches, connection pools, etc). </p> <p>It is the responsibility of the application to ensure that there are no open sessions before calling this method as the impact on those sessions is indeterminate.</p> </blockquote> <p>If you are using the <code>getCurrentSession()</code> method, the typical pattern is to delegate the session opening and closing to Spring and use the <a href="http://static.springsource.org/spring/docs/3.0.x/reference/transaction.html#transaction-declarative" rel="nofollow">@Transactional</a> annotation</p> <pre><code> @Override @Transactional public void empLogin_Dao(Employee employee) { System.out.println("m in dao"); //Please note that declaring mSession as a class member is another no-no //because DAO are typically singletons, so there's only ONE dao and ONE mSession variable //that will be shared by all users - it's possible your class mSession field will be accessed //simultaneously, which will lead to an exception Session mSession = mHibernateSessionFactory.getCurrentSession(); System.out.println(employee.getEmpID()); Query query = mSession .createQuery("from Employee where userName = :username "); query.setParameter("username", employee.getUserName()); List list = query.list(); } </code></pre> <p>You can read about the rollback policy <a href="http://static.springsource.org/spring/docs/3.0.x/reference/transaction.html#transaction-declarative-rolling-back" rel="nofollow">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload