No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

前端 未结 9 761
情歌与酒
情歌与酒 2020-12-23 17:03

I am getting this exception when I call a DAO method which uses SessionFactory.getCurrentSession(). The DAO class is annotated with @Transactional

9条回答
  •  感动是毒
    2020-12-23 18:09

    I was getting the same the error inside a shared function, but it was only happening for some calls to this shared function. I eventually realized that one of classes calling the shared function wasn't wrapping it inside of a Unit of Work. Once I updated this classes functions with a Unit of Work everything worked as expected.

    So just posting this for any future visitors who run into this same error, but for whom the accepted answer doesn't apply.

提交回复
热议问题