Hibernate transaction not successfully started

后端 未结 7 2040
梦谈多话
梦谈多话 2020-12-31 00:15

Consider this simple Hibernate scenario:

session = getHibernateSession();
tx = session.beginTransaction();
SomeObject o = (SomeObject) session.get(SomeObject         


        
7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 00:53

    One situation this can happen in is when the code is in an EJB/MDB using container-managed transactions (CMT), either intentionally or because it's the default. To use bean-managed transactions, add the following annotation:

    @TransactionManagement(TransactionManagementType.BEAN)

    There's more to it than that, but that's the beginning of the story.

提交回复
热议问题