Muhammad Imran Tariq
Muhammad Imran Tariq

Reputation: 23352

HibernateException: No Hibernate Session bound to thread

I am getting this exception and after a lot of R&D i am unable to resolve it.

Basically the error comes when it uses findAll() method located in hbnpojogen-persistence-1.4.4.jar

public abstract interface GenericDAO<T, PK extends Serializable>

  public abstract List<T> findAll();

This is the code that tried to use this method.

HibernateFactory.getDataDao().findAll();

Upvotes: 0

Views: 397

Answers (1)

user41871
user41871

Reputation:

You need to open a transaction before executing findAll(). See e.g. Spring's HibernateTransactionManager and @Transactional annotation.

Upvotes: 1

Related Questions