Replacement for org.hibernate.Transactions.isActive() in Hibernate 5

自闭症网瘾萝莉.ら 提交于 2019-12-01 03:44:09

问题


I'm migrating from hibernate 4.2.17 to 5.0.7 which works fine so far, but it seems that the method isActive is deprecated. I just can't use it anymore.

Here's my code:

public void starteTransaktion() {
        try {
            getMySession();

            if(!hibernateSession.getTransaction().isActive()) {
                hibernateSession.beginTransaction();
            }
        } catch (HibernateException e) {

        }
    }

I substituted all other methods, but I can't quite find a replacement for this...

Error message: The method isActive() is undefined for the type Transaction


回答1:


As per 5.0 Javadoc:

hibernateSession.getTransaction().getStatus() != TransactionStatus.ACTIVE



来源:https://stackoverflow.com/questions/34809098/replacement-for-org-hibernate-transactions-isactive-in-hibernate-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!