我正在将新订单加载到一行中,出于某种原因,我偶尔会在读取一行时收到StaleObjectException:
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [com.example.model.Order#95813]
at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.checkVersion(EntityReferenceInitializerImpl.java:499) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.checkVersion(EntityReferenceInitializerImpl.java:453) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.hydrateEntityState(EntityReferenceInitializerImpl.java:209) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.readRow(AbstractRowReader.java:107) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:129) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:138) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:102) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer.initialize(AbstractLoadPlanBasedCollectionInitializer.java:100) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:693) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:92) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1933) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:558) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:260) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:554) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:142) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.collection.internal.AbstractPersistentCollection$1.doWork(AbstractPersistentCollection.java:171) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.collection.internal.AbstractPersistentCollection$1.doWork(AbstractPersistentCollection.java:156) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:260) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:155) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at org.hibernate.collection.internal.PersistentBag.size(PersistentBag.java:278) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
at sun.reflect.GeneratedMethodAccessor442.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
at javax.el.BeanELResolver.invoke(BeanELResolver.java:183) ~[tomcat7-el-2.2-api.jar:na]
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:161) ~[tomcat7-el-2.2-api.jar:na]
at com.sun.el.parser.AstValue.getValue(AstValue.java:111) ~[el-impl-2.2.jar:na]
at com.sun.el.parser.AstValue.getValue(AstValue.java:163) ~[el-impl-2.2.jar:na]
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219) ~[el-impl-2.2.jar:na]
at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:238) ~[jsf-impl-2.2.7.jar:2.2.7]
at com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(ELText.java:154) ~[jsf-impl-2.2.7.jar:2.2.7]
at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85) ~[jsf-impl-2.2.7.jar:2.2.7]