简体   繁体   中英

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();

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM