1

HibernateOGM を使用して MongoDB と対話したいと考えています。次のcfg.xmlようなファイルがあります。

<hibernate-configuration>
  <session-factory>
      <property name="hibernate.transaction.factory_class">org.transaction.JDBCTransactionFactory</property>
      <property name="hibernate.current_session_context_class">thread</property>
      <property name="hibernate.ogm.datastore.provider">mongodb</property>
      <property name="hibernate.ogm.datastore.grid_dialect">org.hibernate.ogm.dialect.MongoDBDialect</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>
      <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
      <mapping resource="hibernate-contact.hbm.xml"/>    
  </session-factory>
</hibernate-configuration>

POJO クラスも作成しました。メイン クラスでは、mongodb のデータベースにこのコードを入力したいのですが、この仕事を行うことができず、これらの情報行を取得します。どうすれば解決できますか。

Session session=null;
            OgmConfiguration cfgogm=new OgmConfiguration();
            SessionFactory sessionfactory= cfgogm.buildSessionFactory();
            session=sessionfactory.openSession();
            session.beginTransaction();

            System.out.println("Populating the database...");
            Contact cnt=new Contact();
            cnt.setFirstname("Blabla");
            cnt.setLastname("Blabla");
            cnt.setEmail("blabla");
            session.save(cnt);
            session.getTransaction().commit();
            System.out.println("Done... :)");

このコードでは出力がなく、例外もありません

情報行: ここに画像の説明を入力

これは私のプロジェクトの構造です: ここに画像の説明を入力

4

2 に答える 2