【发布时间】:2014-01-12 07:43:58
【问题描述】:
我知道orphanRemoval 属性存在于hibernate-jpa-2.1-api-1.0.0.Final.jar 中,这是我项目中使用的库。
我添加了 Maven 依赖项:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.0.Final</version> </dependency>
我仍然收到错误:The attribute orphanRemoval is undefined for the annotation type OneToMany 在该行中:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "id.store", cascade = {
CascadeType.PERSIST, CascadeType.MERGE }, orphanRemoval=true)
这里有什么问题,我可以做些什么来解决这个问题?
编辑:这些是我的依赖项:
<dependencies> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>${jersey-version}</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> <version>${jersey-version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>${jersey-version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.glassfish.distributions</groupId> <artifactId>web-all</artifactId> <version>10.0-build-20080430</version> <scope>test</scope> </dependency> <dependency> <groupId>org.glassfish.embedded</groupId> <artifactId>gf-embedded-api</artifactId> <version>1.0-alpha-4</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.0.Final</version> </dependency> </dependencies>
【问题讨论】:
-
它也在
hibernate-jpa-2.0中,即。 Java EE 6。你确定你使用的是javax.persistence.OneToMany? -
添加错误堆栈跟踪以获得更好的想法。
-
@suresh 这是一个编译错误。它就在那里。
-
我们可以查看您的其余依赖项吗?
-
是的,导入
javax.persistence.OneToMany在那里。我检查了项目中的 Maven 依赖树,它包含hibernate-jpa-2.1-api-1.0.0.Final.jar。我还检查了课堂OneToMany。它包含cascade、fetch、mappedBy、orphanRemoval和targetEntity。
标签: java eclipse hibernate maven jpa