我是Java EE领域的新手,所以请原谅我的无知;我继承了一个使用guice-persist和hibernate来处理ORM的应用程序。
我正在尝试使用CriteriaQuery
,但我发现我的jaxax.persistence.EntityManager
似乎是this接口(来自EJB),而不是the one I want(来自JPA),所以我无法使用createQuery(CriteriaQuery)
。
这是一个Maven项目,我不清楚这个EJB代码的来源 - 我可以从Guice-Persist和Hibernate看到的所有内容都显示JPA接口,而不是EJB接口,所以我不知道在哪里这个EJB包来自。
这里有什么想法吗?我是否有一个将EJB引入我的项目的流浪Maven依赖,或者听起来像我误解了持久层并且实际上在我的应用程序中需要EJB?
如果您让我知道您需要什么,我会很乐意发布更多信息。
编辑:
经过仔细检查,我开始怀疑我的“远程”项目有一个格式错误的pom.xml。下面的依赖树。
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ texasU ---
[INFO] texasU:texasU:war:1.1.2-SNAPSHOT
[INFO] +- com.google.gwt:gwt-user:jar:2.5.0-rc1:provided
[INFO] | +- (javax.validation:validation-api:jar:1.0.0.GA:compile - scope updat
ed from provided; omitted for duplicate)
[INFO] | +- javax.validation:validation-api:jar:sources:1.0.0.GA:provided
[INFO] | \- org.json:json:jar:20090211:provided
[INFO] +- com.google.gwt:gwt-servlet:jar:2.5.0-rc1:runtime
[INFO] +- com.arcbees.core:arcbees-core:jar:1.0-SNAPSHOT:provided
[INFO] | +- (com.google.gwt:gwt-servlet:jar:2.4.0:provided - omitted for confli
ct with 2.5.0-rc1)
[INFO] | +- com.google.appengine:appengine-api-1.0-sdk:jar:1.6.1:provided
[INFO] | +- (com.gwtplatform:gwtp-dispatch-server-guice:jar:0.8-SNAPSHOT:provid
ed - omitted for duplicate)
[INFO] | +- (com.gwtplatform:gwtp-dispatch-shared:jar:0.8-SNAPSHOT:compile - sc
ope updated from provided; omitted for duplicate)
[INFO] | +- (com.google.inject:guice:jar:3.0:compile - scope updated from provi
ded; omitted for duplicate)
[INFO] | +- (com.google.inject.extensions:guice-servlet:jar:3.0:provided - omit
ted for duplicate)
[INFO] | +- (com.google.inject.extensions:guice-assistedinject:jar:3.0:provided
- omitted for duplicate)
[INFO] | +- javax.persistence:persistence-api:jar:1.0:provided
[INFO] | +- org.restlet.gae:org.restlet:jar:2.1-RC2:provided
[INFO] | \- org.restlet.gae:org.restlet.ext.servlet:jar:2.1-RC2:provided
[INFO] | \- (org.restlet.gae:org.restlet:jar:2.1-RC2:provided - omitted for
duplicate)
[INFO] +- com.gwtplatform:gwtp-mvp-client:jar:0.8-SNAPSHOT:provided
[INFO] | \- com.gwtplatform:gwtp-clients-common:jar:0.8-SNAPSHOT:provided
[INFO] | \- (com.google.inject:guice:jar:3.0:provided - omitted for duplicat
e)
[INFO] +- com.gwtplatform:gwtp-dispatch-client:jar:0.8-SNAPSHOT:provided
[INFO] | +- (com.gwtplatform:gwtp-clients-common:jar:0.8-SNAPSHOT:provided - om
itted for duplicate)
[INFO] | +- (com.gwtplatform:gwtp-dispatch-shared:jar:0.8-SNAPSHOT:provided - o
mitted for duplicate)
[INFO] | \- (com.google.inject:guice:jar:3.0:provided - omitted for duplicate)
[INFO] +- com.gwtplatform:gwtp-dispatch-server-guice:jar:0.8-SNAPSHOT:compile
[INFO] | +- com.gwtplatform:gwtp-dispatch-server:jar:0.8-SNAPSHOT:compile
[INFO] | | \- (com.gwtplatform:gwtp-dispatch-shared:jar:0.8-SNAPSHOT:compile -
omitted for duplicate)
[INFO] | +- (com.gwtplatform:gwtp-dispatch-shared:jar:0.8-SNAPSHOT:compile - om
itted for duplicate)
[INFO] | \- (com.google.inject:guice:jar:3.0:compile - omitted for duplicate)
[INFO] +- com.gwtplatform:gwtp-dispatch-shared:jar:0.8-SNAPSHOT:compile
[INFO] +- com.gwtplatform:gwtp-processors:jar:0.8-SNAPSHOT:provided
[INFO] +- com.google.inject:guice:jar:3.0:compile
[INFO] | +- javax.inject:javax.inject:jar:1:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- com.google.inject.extensions:guice-servlet:jar:3.0:compile
[INFO] | \- (com.google.inject:guice:jar:3.0:compile - omitted for duplicate)
[INFO] +- com.google.inject.extensions:guice-assistedinject:jar:3.0:compile
[INFO] | \- (com.google.inject:guice:jar:3.0:compile - omitted for duplicate)
[INFO] +- com.google.gwt.inject:gin:jar:1.5.0:provided
[INFO] | +- (com.google.inject:guice:jar:3.0-rc2:provided - omitted for conflic
t with 3.0)
[INFO] | +- (com.google.inject.extensions:guice-assistedinject:jar:3.0-rc2:prov
ided - omitted for conflict with 3.0)
[INFO] | \- (com.google.gwt:gwt-servlet:jar:2.2.0:provided - omitted for confli
ct with 2.5.0-rc1)
[INFO] +- mysql:mysql-connector-java:jar:5.1.21:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.1.4.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar
:1.0.0.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Fin
al:compile
[INFO] | +- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] | \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:
compile
[INFO] | \- (org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile - omitted
for conflict with 3.1.0.GA)
[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.1.4.Final:compile
[INFO] | +- (org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile - omitted for
duplicate)
[INFO] | +- (org.hibernate:hibernate-core:jar:4.1.4.Final:compile - omitted for
duplicate)
[INFO] | +- (org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:ja
r:1.0.0.Final:compile - omitted for duplicate)
[INFO] | +- (dom4j:dom4j:jar:1.6.1:compile - omitted for duplicate)
[INFO] | +- (org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Fi
nal:compile - omitted for duplicate)
[INFO] | +- (org.javassist:javassist:jar:3.15.0-GA:compile - omitted for duplic
ate)
[INFO] | \- (org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final
:compile - omitted for duplicate)
[INFO] +- org.hibernate:hibernate-validator:jar:4.3.0.Final:compile
[INFO] | +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] | \- (org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile - omitted fo
r conflict with 3.1.0.GA)
[INFO] +- com.google.inject.extensions:guice-persist:jar:3.0:compile
[INFO] | \- (com.google.inject:guice:jar:3.0:compile - omitted for duplicate)
[INFO] +- org.hibernate:hibernate-c3p0:jar:4.1.4.Final:compile
[INFO] | +- (org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile - omitted for
duplicate)
[INFO] | +- (org.hibernate:hibernate-core:jar:4.1.4.Final:compile - omitted for
duplicate)
[INFO] | \- c3p0:c3p0:jar:0.9.1:compile
[INFO] +- com.googlecode.gwtquery:gwtquery:jar:1.1.0:provided
[INFO] +- com.google.guava:guava:jar:13.0-rc2:compile
[INFO] +- com.google.guava:guava-gwt:jar:13.0-rc2:provided
[INFO] | \- (com.google.guava:guava:jar:13.0-rc2:provided - omitted for duplica
te)
[INFO] +- org.mindrot:jbcrypt:jar:0.3m:compile
[INFO] +- javax.mail:mail:jar:1.4.5:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- edu.utsouthwestern.qbri.remoter:service-bundle:jar:1.0-SNAPSHOT:compil
e
[INFO] | +- org.nuiton.thirdparty:Rserve:jar:0.6-1:compile
[INFO] | +- org.nuiton.thirdparty:REngine:jar:0.6-1:compile
[INFO] | +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.5.1:compile
[INFO] | | +- xml-resolver:xml-resolver:jar:1.2:compile
[INFO] | | +- asm:asm:jar:3.3:compile
[INFO] | | +- org.apache.cxf:cxf-api:jar:2.5.1:compile
[INFO] | | | +- org.apache.cxf:cxf-common-utilities:jar:2.5.1:compile
[INFO] | | | | +- (org.apache.ws.xmlschema:xmlschema-core:jar:2.0.1:compile
- omitted for duplicate)
[INFO] | | | | \- org.codehaus.woodstox:woodstox-core-asl:jar:4.1.1:runtime
[INFO] | | | | \- org.codehaus.woodstox:stax2-api:jar:3.1.1:runtime
[INFO] | | | +- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.1:compile
[INFO] | | | +- org.apache.neethi:neethi:jar:3.0.1:compile
[INFO] | | | \- wsdl4j:wsdl4j:jar:1.6.2:compile
[INFO] | | +- org.apache.cxf:cxf-rt-core:jar:2.5.1:compile
[INFO] | | | +- (org.apache.cxf:cxf-api:jar:2.5.1:compile - omitted for dupli
cate)
[INFO] | | | +- com.sun.xml.bind:jaxb-impl:jar:2.1.13:compile
[INFO] | | | +- (org.apache.ws.xmlschema:xmlschema-core:jar:2.0.1:compile - o
mitted for duplicate)
[INFO] | | | \- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.
1:compile
[INFO] | | +- org.apache.cxf:cxf-rt-bindings-soap:jar:2.5.1:compile
[INFO] | | | +- (org.apache.cxf:cxf-api:jar:2.5.1:compile - omitted for dupli
cate)
[INFO] | | | +- org.apache.cxf:cxf-tools-common:jar:2.5.1:compile
[INFO] | | | | +- (wsdl4j:wsdl4j:jar:1.6.2:compile - omitted for duplicate)
[INFO] | | | | +- (com.sun.xml.bind:jaxb-impl:jar:2.1.13:compile - omitted f
or duplicate)
[INFO] | | | | +- (org.apache.cxf:cxf-api:jar:2.5.1:compile - omitted for du
plicate)
[INFO] | | | | +- (org.apache.cxf:cxf-common-utilities:jar:2.5.1:compile - o
mitted for duplicate)
[INFO] | | | | \- (org.apache.cxf:cxf-rt-core:jar:2.5.1:compile - omitted fo
r duplicate)
[INFO] | | | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.5.1:compile
[INFO] | | | +- (org.apache.cxf:cxf-api:jar:2.5.1:compile - omitted for du
plicate)
[INFO] | | | +- (org.apache.cxf:cxf-rt-core:jar:2.5.1:compile - omitted fo
r duplicate)
[INFO] | | | \- (com.sun.xml.bind:jaxb-impl:jar:2.1.13:compile - omitted f
or duplicate)
[INFO] | | +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.5.1:compile
[INFO] | | | +- (org.apache.cxf:cxf-api:jar:2.5.1:compile - omitted for dupli
cate)
[INFO] | | | \- (org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.5.1:compile - o
mitted for duplicate)
[INFO] | | +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.5.1:compile
[INFO] | | | +- (org.apache.cxf:cxf-api:jar:2.5.1:compile - omitted for dupli
cate)
[INFO] | | | +- (org.apache.cxf:cxf-rt-core:jar:2.5.1:compile - omitted for d
uplicate)
[INFO] | | | \- (org.apache.cxf:cxf-rt-bindings-soap:jar:2.5.1:compile - omit
ted for duplicate)
[INFO] | | \- org.apache.cxf:cxf-rt-ws-addr:jar:2.5.1:compile
[INFO] | | +- (org.apache.cxf:cxf-api:jar:2.5.1:compile - omitted for dupli
cate)
[INFO] | | +- (org.apache.cxf:cxf-common-utilities:jar:2.5.1:compile - omit
ted for duplicate)
[INFO] | | \- (org.apache.cxf:cxf-rt-bindings-soap:jar:2.5.1:compile - omit
ted for duplicate)
[INFO] | \- org.apache.cxf:cxf-rt-transports-http:jar:2.5.1:compile
[INFO] | +- (org.apache.cxf:cxf-api:jar:2.5.1:compile - omitted for duplicat
e)
[INFO] | +- org.apache.cxf:cxf-rt-transports-common:jar:2.5.1:compile
[INFO] | | +- (org.apache.cxf:cxf-api:jar:2.5.1:compile - omitted for dupli
cate)
[INFO] | | \- (org.apache.cxf:cxf-rt-core:jar:2.5.1:compile - omitted for d
uplicate)
[INFO] | +- (org.apache.cxf:cxf-rt-core:jar:2.5.1:compile - omitted for dupl
icate)
[INFO] | \- org.springframework:spring-web:jar:3.0.6.RELEASE:compile
[INFO] | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplic
ate)
[INFO] | +- org.springframework:spring-beans:jar:3.0.6.RELEASE:compile
[INFO] | | \- (org.springframework:spring-core:jar:3.0.6.RELEASE:compile
- omitted for duplicate)
[INFO] | +- org.springframework:spring-context:jar:3.0.6.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:3.0.6.RELEASE:compile
[INFO] | | | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for
duplicate)
[INFO] | | | +- (org.springframework:spring-asm:jar:3.0.6.RELEASE:compi
le - omitted for duplicate)
[INFO] | | | +- (org.springframework:spring-beans:jar:3.0.6.RELEASE:com
pile - omitted for duplicate)
[INFO] | | | \- (org.springframework:spring-core:jar:3.0.6.RELEASE:comp
ile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:3.0.6.RELEASE:compil
e - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-core:jar:3.0.6.RELEASE:compile
- omitted for duplicate)
[INFO] | | +- org.springframework:spring-expression:jar:3.0.6.RELEASE:co
mpile
[INFO] | | | \- (org.springframework:spring-core:jar:3.0.6.RELEASE:comp
ile - omitted for duplicate)
[INFO] | | \- org.springframework:spring-asm:jar:3.0.6.RELEASE:compile
[INFO] | \- org.springframework:spring-core:jar:3.0.6.RELEASE:compile
[INFO] | +- (org.springframework:spring-asm:jar:3.0.6.RELEASE:compile
- omitted for duplicate)
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.apache.commons:commons-io:jar:1.3.2:compile
[INFO] +- com.googlecode.gwt.charts:gwt-charts:jar:0.9.5:compile
[INFO] +- junit:junit:jar:4.10:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- org.mockito:mockito-all:jar:1.9.5-rc1:test
[INFO] +- org.jukito:jukito:jar:1.1:test
[INFO] | +- org.mockito:mockito-core:jar:1.8.5:test
[INFO] | | +- (org.hamcrest:hamcrest-core:jar:1.1:test - omitted for duplicate
)
[INFO] | | \- org.objenesis:objenesis:jar:1.0:test
[INFO] | +- (junit:junit:jar:4.5:test - omitted for conflict with 4.10)
[INFO] | +- (com.google.inject:guice:jar:3.0:test - omitted for duplicate)
[INFO] | \- (com.google.inject.extensions:guice-assistedinject:jar:3.0:test - o
mitted for duplicate)
[INFO] +- org.seleniumhq.selenium:selenium-java:jar:2.22.0:test
[INFO] | +- org.seleniumhq.selenium:selenium-android-driver:jar:2.22.0:test
[INFO] | | \- org.seleniumhq.selenium:selenium-remote-driver:jar:2.22.0:test
[INFO] | | +- cglib:cglib-nodep:jar:2.1_3:test
[INFO] | | +- (org.json:json:jar:20080701:test - omitted for conflict with
20090211)
[INFO] | | +- (org.seleniumhq.selenium:selenium-api:jar:2.22.0:test - omitt
ed for duplicate)
[INFO] | | +- (org.apache.httpcomponents:httpclient:jar:4.1.2:test - omitte
d for duplicate)
[INFO] | | +- (com.google.guava:guava:jar:12.0:test - omitted for conflict
with 13.0-rc2)
[INFO] | | +- (org.apache.commons:commons-exec:jar:1.1:test - omitted for d
uplicate)
[INFO] | | +- (net.java.dev.jna:jna:jar:3.4.0:test - omitted for duplicate)
[INFO] | | \- (net.java.dev.jna:platform:jar:3.4.0:test - omitted for dupli
cate)
[INFO] | +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.22.0:test
[INFO] | | \- (org.seleniumhq.selenium:selenium-remote-driver:jar:2.22.0:test
- omitted for duplicate)
[INFO] | +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.22.0:test
[INFO] | | +- org.seleniumhq.selenium:selenium-api:jar:2.22.0:test
[INFO] | | | \- (com.google.guava:guava:jar:12.0:test - omitted for conflict
with 13.0-rc2)
[INFO] | | +- net.sourceforge.htmlunit:htmlunit:jar:2.9:test
[INFO] | | | +- xalan:xalan:jar:2.7.1:test
[INFO] | | | | \- xalan:serializer:jar:2.7.1:test
[INFO] | | | | \- (xml-apis:xml-apis:jar:1.3.04:test - omitted for duplic
ate)
[INFO] | | | +- commons-collections:commons-collections:jar:3.2.1:test
[INFO] | | | +- commons-lang:commons-lang:jar:2.6:test
[INFO] | | | +- org.apache.httpcomponents:httpmime:jar:4.1.2:test
[INFO] | | | | +- (org.apache.httpcomponents:httpcore:jar:4.1.2:test - omitt
ed for duplicate)
[INFO] | | | | \- (commons-logging:commons-logging:jar:1.1.1:test - omitted
for duplicate)
[INFO] | | | +- commons-codec:commons-codec:jar:1.4:test
[INFO] | | | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.9:test
[INFO] | | | +- xerces:xercesImpl:jar:2.9.1:test
[INFO] | | | | \- xml-apis:xml-apis:jar:1.3.04:test
[INFO] | | | +- net.sourceforge.nekohtml:nekohtml:jar:1.9.15:test
[INFO] | | | +- net.sourceforge.cssparser:cssparser:jar:0.9.5:test
[INFO] | | | | \- org.w3c.css:sac:jar:1.3:test
[INFO] | | | +- (commons-io:commons-io:jar:2.0.1:test - omitted for duplicate
)
[INFO] | | | \- (commons-logging:commons-logging:jar:1.1.1:compile - scope up
dated from test; omitted for duplicate)
[INFO] | | \- org.apache.httpcomponents:httpclient:jar:4.1.2:test
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.1.2:test
[INFO] | | \- (commons-logging:commons-logging:jar:1.1.1:compile - scope up
dated from test; omitted for duplicate)
[INFO] | +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.22.0:test
[INFO] | | +- (org.seleniumhq.selenium:selenium-remote-driver:jar:2.22.0:test
- omitted for duplicate)
[INFO] | | +- commons-io:commons-io:jar:2.0.1:test
[INFO] | | \- org.apache.commons:commons-exec:jar:1.1:test
[INFO] | +- org.seleniumhq.selenium:selenium-ie-driver:jar:2.22.0:test
[INFO] | | +- net.java.dev.jna:jna:jar:3.4.0:test
[INFO] | | +- net.java.dev.jna:platform:jar:3.4.0:test
[INFO] | | \- (org.seleniumhq.selenium:selenium-remote-driver:jar:2.22.0:test
- omitted for duplicate)
[INFO] | +- org.seleniumhq.selenium:selenium-iphone-driver:jar:2.22.0:test
[INFO] | | \- (org.seleniumhq.selenium:selenium-remote-driver:jar:2.22.0:test
- omitted for duplicate)
[INFO] | +- org.seleniumhq.selenium:selenium-safari-driver:jar:2.22.0:test
[INFO] | | +- (org.seleniumhq.selenium:selenium-remote-driver:jar:2.22.0:test
- omitted for duplicate)
[INFO] | | \- (org.webbitserver:webbit:jar:0.4.6:test - omitted for duplicate)
[INFO] | +- org.seleniumhq.selenium:selenium-support:jar:2.22.0:test
[INFO] | | \- (org.seleniumhq.selenium:selenium-api:jar:2.22.0:test - omitted
for duplicate)
[INFO] | \- org.webbitserver:webbit:jar:0.4.6:test
[INFO] | \- org.jboss.netty:netty:jar:3.2.7.Final:test
[INFO] +- info.cukes:cucumber-java:jar:1.0.11:test
[INFO] | \- info.cukes:cucumber-core:jar:1.0.11:test
[INFO] | +- info.cukes:gherkin:jar:2.11.1:test
[INFO] | \- info.cukes:cucumber-html:jar:0.2.1:test
[INFO] +- info.cukes:cucumber-guice:jar:1.0.11:test
[INFO] | \- (info.cukes:cucumber-java:jar:1.0.11:test - omitted for duplicate)
[INFO] \- info.cukes:cucumber-junit:jar:1.0.11:test
[INFO] \- (info.cukes:cucumber-core:jar:1.0.11:test - omitted for duplicate)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.014s
[INFO] Finished at: Tue Sep 11 09:08:32 CDT 2012
[INFO] Final Memory: 13M/218M
[INFO] ------------------------------------------------------------------------
RemoteR应该是一个自动运行的CXF SOAP Web服务。我在这个项目中想要的只是“客户端”部分,它能够向其他地方托管的Web服务发出请求。因此,在我当前的项目中看到Spring依赖性让我怀疑我可能在这里遇到了一些JPA冲突。
答案 0 :(得分:1)
你在这里混淆了很多想法,让我澄清......
第一个JPA与EJB - JPA代表java持久性架构 - 它是一个规范,是Java EE规范的一部分,它描述了如何实现ORM并将您的东西存储在数据库中。它可以通过hibernate,toplink或任何其他ORM框架实现。
现在,EJB - 代表Enterprise Java Beans是另一个解决业务逻辑的规范,并定义了如何创建远程调用的代码。 从历史上看(在EJB3之前),ejb的规范提到了JPA和EJB,因此混合了。但现在分离非常明确。
关于你的问题。
javax.persistence.EntityManager是一个JPA类,但整个Criteria API仅在JPA 2.0中添加 所以你的第一个链接不包括它只是因为它描述了JPA 1.0规范
你应该怎么做? 答案与往常一样“取决于”:)
在理想世界中,我会告诉你类似的事情:“升级到JPA 2.0并使用Criteria API”
从技术上讲,你应该更新你的pom.xml中的依赖版本(你说你的项目是mavenized),你会没事的。
然而在实践中并非那么容易:
Java EE是由容器(a.k.a.应用程序服务器)实现的,所以你可能在JBoss / Glassfish / WebShere中运行你的项目,你可以命名它。 通常,每个版本的应用程序服务器都在Java EE上实现特定版本。
JPA 1.0是Java EE 5.0的一部分,JPA 2.0(标准为api)是Java EE 6.0的一部分
因此,如果您真的想使用此条件api,那么您应该确保应用程序服务器能够运行Java EE 6.
我要提到的另一个问题是,ORM框架也在不断发展,所以如果你正在升级,你会得到更新版本的,例如,hibernate。
这可能会引入一些不一致,尤其是在复杂的查询中。
所以选择权归你所有。
免责声明:我没有使用过guice-persist,所以我的答案解决了在Java EE容器内运行的应用程序。
希望有所帮助
答案 1 :(得分:1)
您可以通过
查看哪些家属包含传递依赖项 mvn dependency:tree
但是我认为这个jar来自你的应用服务器。它偶然是jOnAS吗?
这是依赖于实现JPA
的Hibernate的示例 <properties>
<hibernate.version>4.1.4-Final</hibernate.version>
</properties>
......
......
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>${hibernate.version}</version>
</dependency>