1

HibernateDAOFactoryクラスのLinkに基づいてDAOを実装しましたが、メソッドがあります

protected Session getCurrentSession() {
     return HibernateUtil.getSessionFactory().getCurrentSession();
}

同じことを実装するために、以下の記事 説明されているように、hibernate.cfg.xmlを変更しました。

    <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property><br/>
    <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
    <property name="hibernate.current_session_context_class">thread</property>

jbossにデプロイしているときに、次のエラーが発生します

org.hibernate.TransactionException: could not register synchronization

プロパティも設定しました

<property name="hibernate.current_session_context_class">jta</property>

しかし、私は次のエラーが発生しました。

 Caused by: org.hibernate.HibernateException: Unable to locate current JTA transaction

 at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:88)

 at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)

私はここで何かを逃していますか?私のjbossバージョンは4.2.3で、Hibernateバージョンは3.3.1で、Java7を使用しています。

4

1 に答える 1

0

スレッドベースのセッション管理では、hibernate.cfg.xmlからtransaction.factory_classandmanager_lookup_classプロパティを削除しましたが、これは魅力のように機能しました。
しかし、jtaベースのセッション管理の場合、同じエラーが発生します。

于 2012-10-08T17:53:42.000 に答える