我知道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>
答案 0 :(得分:1)
glassfish web-all依赖项还包含JPA包,它包含旧版本(从2008-04-30开始,因为artefact的版本表示,所以可能是JPA 1.0)。
您可以在此处查看此依赖项中包含的软件包:http://mvnrepository.com/artifact/org.glassfish.distributions/web-all/10.0-build-20080430。
答案 1 :(得分:1)
添加了hibernate-jpa-2.0-api-1.0.0.Final.jar
并删除了persistence.jar
在参考库中的orphanRemoval()
包中没有javax.persistence
方法的private static List<MyObj> teste;
public static List<MyObj> Teste;
{
get {return Teste;}
set
{
teste.Add(new MyObj{ Value = 1, Quant = 1 });
teste.Add(new MyObj{ Value = 2, Quant = 1 });
teste.Add(new MyObj{ Value = 99, Quant = 1 });
teste.Add(new MyObj{ Value = 33, Quant = 1 });
}
}
。这解决了错误
&#34;注释类型未定义属性orphanRemoval 一对多&#34;