HbnContainer session management (no active transaction)

I want to use a table with HbnContainer however I face a problem with sessiom management.

I initialize HbnContainer in a constructor of my View:

Session currentSession = HibernateUtil.getSessionFactory()
                .openSession();
        if(!currentSession.getTransaction().isActive()) {
            currentSession.beginTransaction();
        }
        ThreadLocalSessionContext.bind(currentSession);

    customContainer = new HbnContainer<User>(User.class, HibernateUtil.getSessionFactory());

I thought this get’s me current session and begins a transaction. I found in Internet information that getTransaction doesnt bind the session, so that I do it with TrheadLocalSessionContext.bind

I use automatic session context management

<property name="current_session_context_class">thread</property>

This causes
org.hibernate.HibernateException: createCriteria is not valid without active transaction

Unfortunatelly HbnContainer sample is out of date and I can’t use TransactionListener anymore…

Thnx in advance for any suggestions,