如何从默认的Hibernate转换为Hibernate OGM

时间:2019-04-22 12:19:17

标签: hibernate jpa web-applications

我有一个maven项目,该项目创建一个.WAR Web服务(以及具有相同战争但嵌入了tomcat的.JAR),并且最初使用Hibernate。我现在正尝试使用MongoDB将这个项目从Hibernate转换为Hibernate OGM,因为我需要获得两者之间的性能时间比较。但我真的不知道如何进行转换。

有了此更改,它可以毫无问题地进行编译,但是我不知道它是否使用OGM框架而不是原始的(关系的)框架。我现在迷失了,如果有人告诉我如何查看我是否在使用OGM,如果没有,我乍看之下我的程序需要进行哪些更改。

最近两天我都看过教程,并且在pom.xml文件中包含了休眠ogm所需的所有依赖关系,并且我尝试在src / META-INF / persistence.xml和src /中创建persistence.xml。 main / resources / META-INF / persistence.xml以便使用此配置(即使我在原始项目中找不到此文件)。

这是我的pom.xml依赖项

    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>
        </dependency>
        <!-- JAVA RX -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.1</version>
        </dependency>
        <!-- JERSEY -->
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet</artifactId>
            <version>2.27</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
            <version>2.27</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.ext</groupId>
            <artifactId>jersey-declarative-linking</artifactId>
            <version>2.27</version>
        </dependency>
        <!-- JACKSON -->
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>2.27</version>
        </dependency>
        <!-- LOG4J -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency>
        <!-- SWAGGER -->
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-jersey2-jaxrs</artifactId>
            <version>1.5.0</version>
        </dependency>
        <!-- HIBERNATE -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.10.Final</version>
        </dependency>
        <!-- Hibernate OGM Infinispan module; pulls in the OGM core module -->
        <dependency>
            <groupId>org.hibernate.ogm</groupId>
            <artifactId>hibernate-ogm-infinispan-embedded</artifactId>
        </dependency>
        <!-- Optional, needed to run JPQL queries on some datastores -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-search-orm</artifactId>
            <version>5.11.1.Final</version>
        </dependency>
        <!-- Standard APIs dependencies - provided in a Java EE container -->
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.2.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.2_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate.ogm</groupId>
            <artifactId>hibernate-ogm-mongodb</artifactId>
        </dependency>
        <!-- Add the Narayana Transactions Manager an implementation would be provided in a Java EE container, but this works nicely in Java SE as well -->
        <dependency>
            <groupId>org.jboss.narayana.jta</groupId>
            <artifactId>narayana-jta</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jboss-transaction-spi</artifactId>
            <version>7.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-c3p0</artifactId>
            <version>3.6.10.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.16.1-GA</version>
        </dependency>
        <!-- C3P0 -->
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.2.1</version>
        </dependency>
        <!-- DERBY -->
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>10.13.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derbyclient</artifactId>
            <version>10.13.1.1</version>
        </dependency>
        <!-- MYSQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.14</version>
        </dependency>
        <!-- POSTGRES -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.1.4</version>
        </dependency>
        <!-- UIMA -->
        <dependency>
            <groupId>org.apache.uima</groupId>
            <artifactId>uimafit-core</artifactId>
            <version>2.4.0</version>
        </dependency>
        <!-- DKPRO -->
        <dependency>
            <groupId>de.tudarmstadt.ukp.dkpro.core</groupId>
            <artifactId>de.tudarmstadt.ukp.dkpro.core.clearnlp-asl</artifactId>
            <version>1.8.0</version>
        </dependency>
        <!-- DKPRO Models -->
        <dependency>
            <groupId>de.tudarmstadt.ukp.dkpro.core</groupId>
            <artifactId>de.tudarmstadt.ukp.dkpro.core.clearnlp-model-dictionary-en-default</artifactId>
            <version>20130715.0</version>
        </dependency>
        <dependency>
            <groupId>de.tudarmstadt.ukp.dkpro.core</groupId>
            <artifactId>de.tudarmstadt.ukp.dkpro.core.clearnlp-model-tagger-en-ontonotes</artifactId>
            <version>20131128.0</version>
        </dependency>

    </dependencies>

有了此更改,它可以毫无问题地进行编译,但是我不知道它是否使用OGM框架而不是原始的(关系的)框架。现在我迷路了,如果有人告诉我如何查看我是否在使用OGM,如果没有,我乍看之下我的程序需要进行哪些更改。

0 个答案:

没有答案