我有三张桌子。表A用复合FK引用表B和C. 当我这么做时:
A a = (A) em.find(A.class, aPk);
它给了我ConcurrentModificationException。 关于什么会出错的任何指针?
@Entity
public class A implements Serializable {
@EmbeddedId
private APK pk;
@OneToOne(cascade=CascadeType.ALL)
private B b;
@OneToOne(cascade=CascadeType.ALL)
private C c;
}
@Entity
public class B implements Serializable {
@EmbeddedId
private BPK pk;
...
}
@Entity
public class C implements Serializable {
@EmbeddedId
private CPK pk;
...
}
堆栈追踪:
Caused by: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
at java.util.HashMap$KeyIterator.next(HashMap.java:828)
at org.apache.openjpa.kernel.ManagedCache.dirtyCheck(ManagedCache.java:307)
at org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.java:3820)
at org.apache.openjpa.kernel.BrokerImpl.addToTransaction(BrokerImpl.java:3892)
at org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.java:216)
at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:313)
at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:275)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:351)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:278)
at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:913)
at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:871)
答案 0 :(得分:0)
使用运行时增强器后,大多数问题都会消失。