0

私は問題があります。私は休止状態が初めてで、HibernateOGM を使用して非常に単純な例を書きたいと思っています。次のような例外が発生します。

原因: org.hibernate.HibernateException: 指定された TransactionFactory クラスをインスタンス化できません [org.transaction.JDBCTransactionFactory]

私は本当にたくさん検索しましたが、問題の解決策が見つかりませんでした。私が理解しているように、問題は次の行で発生します。

sessionfactory=cfgogm.buildSessionFactory(serviceregistry);

他の行にコメントすると、例外はなく、INFOS だけです。

これは私のスタックトレースです:

at org.hibernate.engine.transaction.internal.TransactionFactoryInitiator.initiateService(TransactionFactoryInitiator.java:80)
    at org.hibernate.ogm.transaction.impl.OgmTransactionFactoryInitiator.buildServiceInstance(OgmTransactionFactoryInitiator.java:61)
    at org.hibernate.ogm.transaction.impl.OgmTransactionFactoryInitiator.buildServiceInstance(OgmTransactionFactoryInitiator.java:41)
    at org.hibernate.ogm.service.impl.OptionalServiceInitiator.initiateService(OptionalServiceInitiator.java:37)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176)

ここに私のコードと hibernate.cfg.xml と pom.xml があります:

 OgmConfiguration cfgogm=new OgmConfiguration();
            cfgogm.configure("hibernate.cfg.xml");
            serviceregistry=new ServiceRegistryBuilder().applySettings(cfgogm.getProperties()).buildServiceRegistry();
            sessionfactory=cfgogm.buildSessionFactory(serviceregistry)

hibernate.cfg.xmlは:

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>  
  <session-factory>


    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.ogm.datastore.grid_dialect">org.hibernate.ogm.dialect.mongodb.MongoDBDialect</property>
    <property name="hibernate.ogm.datastore.provider">mongodb</property>
    <property name="hibernate.ogm.mongodb.database">rcfdb</property>
    <property name="hibernate.ogm.mongodb.host">127.0.0.1</property>
    <property name="hibernate.ogm.mongodb.port">27017</property>
    <mapping resource="hibernate-contact.hbm.xml"/>
  </session-factory>
</hibernate-configuration>

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>hogm</groupId>
  <artifactId>HibernateOGM_MongoDB</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>HibernateOGM_MongoDB</name>
  <url>http://maven.apache.org</url>
  <build>
          <plugins>
              <plugin>
                  <groupId>org.codehaus.mojo</groupId>
                  <artifactId>exec-maven-plugin</artifactId>
                  <version>1.2.1</version>
                  <executions>
                      <execution>
                          <goals>
                                  <goal>exec</goal>
                          </goals>
                      </execution>
                  </executions>
              </plugin>
          </plugins>
  </build>

 <dependencies>
     <dependency>
         <groupId>org.hibernate.ogm</groupId>
         <artifactId>hibernate-ogm-mongodb</artifactId>
         <version>4.0.0.Beta1</version>
     </dependency>
     <dependency>
         <groupId>org.hibernate.ogm</groupId>
         <artifactId>hibernate-ogm-core</artifactId>
         <version>4.0.0.Beta2</version>
     </dependency>   

  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.11</version>
   <scope>test</scope>
   <type>jar</type>
  </dependency>
 </dependencies>
</project>

この問題を解決するのを手伝ってもらえますか?

4

2 に答える 2

2

正しいクラス名は org. hibernate .transaction.JDBCTransactionFactory.

おそらく休止状態は、間違ったクラス名を持ついくつかのプロパティまたはプロパティ ファイルを取得します。

見つからない場合は、独自の hibernate.cfg.xml でオーバーライドします。

<property  name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
于 2013-08-14T14:04:34.217 に答える
1

Hibernate Object/Grid Mapper (OGM) は、 NoSQLデータストアの Java Persistence (JPA) サポートを提供する永続エンジンです。では、なぜderby でhibernate-ogmを使用するのですか?

mangoDB を使用した hibernate-ogmの公式ガイドを確認してください

- 編集 -

構成ファイルのいずれかにJDBCTransactionFactoryのようなものはありますか? 削除してみてください。

于 2013-08-14T12:59:17.460 に答える