对于EntityManager类型,createEntityGraph(Class<>)方法是未定义的 [英] The method createEntityGraph(Class<>) is undefined for the type EntityManager
本文介绍了对于EntityManager类型,createEntityGraph(Class<>)方法是未定义的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码行:
EntityGraph<Patient> graph = this.em.createEntityGraph(Patient.class);
在eclipse中导致以下编译错误:
is causing the following compilation error in eclipse:
The method createEntityGraph(Class<SomeClass>) is undefined for the type EntityManager
$的方法createEntityGraph(Class< SomeClass>) b $ b
如何解决此错误?
How can I resolve this error?
以下是我的pom.xml的相关部分:
Here are the relevant parts of my pom.xml:
<properties>
<!-- Generic properties -->
<java.version>1.7</java.version>
<!-- Spring -->
<spring-framework.version>4.0.6.RELEASE</spring-framework.version>
<spring-data-jpa.version>1.6.4.RELEASE</spring-data-jpa.version>
<!-- Hibernate / JPA -->
<hibernate.version>4.3.5.Final</hibernate.version>
<!-- Bean validation -->
<hibernate-validator.version>5.1.1.Final</hibernate-validator.version>
<!-- Database access -->
<tomcat-jdbc.version>7.0.42</tomcat-jdbc.version>
<mysql.version>5.1.27</mysql.version>
<!-- AOP -->
<aspectj.version>1.7.4</aspectj.version>
</properties>
<dependencies>
<!-- hyperjaxb dependencies -->
<dependency>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>hyperjaxb3-ejb-runtime</artifactId>
<version>0.6.0</version>
</dependency>
<!-- Roundtrip -->
<dependency>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>hyperjaxb3-ejb-roundtrip</artifactId>
<version>0.6.0</version>
</dependency>
<!-- SPRING, SPRING, SPRINGITY SPRING -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring-data-jpa.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<!-- used for EhCcheCcheManager -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring-framework.version}</version>
<exclusions>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<!-- Database connection pool -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>${tomcat-jdbc.version}</version>
<scope>runtime</scope>
</dependency>
<!-- For MySql only -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- HIBERNATE -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate-validator.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>${hibernate.version}</version>
</dependency>
</dependencies>
此外, JPA版本
设置在eclipse项目方面 2.1
In addition, the JPA version
is set to 2.1
in the eclipse project facet.
推荐答案
您的jee7项目是没有正确设置你必须添加这种依赖关系:
Your jee7 project is not properly set up you have to add this dependency:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
这篇关于对于EntityManager类型,createEntityGraph(Class<>)方法是未定义的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文