CollectionOfElements 上的 java.util.ConcurrentModificationException

标签 java hibernate jpa concurrency

当我在 Embedabble 中有一个 CollectionOfElements 时,我似乎得到了一个 ConcurrentModificationException。

如果我想那样做,但是如果我将路由从 Embedabble 更改为实体,那么一切都会正常进行。我什至尝试添加 @Version,但这似乎不起作用。

这是我的类(class)片段。 卡丁车.java:

@Entity
public class Kart {

@Id @GeneratedValue
private Long id;

@Column(nullable=false,length=256)
@NotNull
@Length(max=256)
private String name;

@OneToOne(cascade=CascadeType.ALL)
private File file;

@Version
private int version;

@CollectionOfElements
private Set<Route> route;

路由.java:

@Embeddable
public class Route {

@Parent
private Kart kart;

@NotNull
@Column(nullable = false, length = 256)
private String name;

@NotNull
@Column(nullable = false)
private Boolean visible = Boolean.valueOf(true);

@CollectionOfElements
private Set<Coordinates> coordinates;

@Version
private int version;

坐标.java:

@Embeddable
public class Coordinates {

@NotNull
private int x;

@NotNull
private int y;

@Parent
private Route route;

@Version
private int version;

我已经为坐标和路线生成了 Hashcode/equals

最佳答案

检查此 JIRA 条目。

ConcurrentModificationException when collection of embeddable contains a collection

这是 Annotation Binder 中的一个已知错误。问题在于 Hibernate Core 不支持嵌入式集合中的集合。

关于CollectionOfElements 上的 java.util.ConcurrentModificationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1589409/

相关文章:

java - 如何让EhCache重置一个域与其他域之间的一对多关系的缓存?

jpa - 如何在JPA下解锁一个实体

java - GC 如何在范围中间工作

java - 使用toString方法打印ArrayList内容时出错

java - 如何防止异常时自动递增?

java - 使用 ejb、java 持久性实体管理器的两个数据库连接

java - Hibernate : org. hibernate.PropertyAccessException:IllegalArgumentException

java并发与scheduledexecutor和无限循环

java - 当我需要在命令类之外的表单上显示数据时,如何使用 SimpleFormController?

spring - 创建 EntityManagerFactory 时出现异常 - 在 SerialContext 中查找 'persistence/myPU' 失败