嗨,我有一个包含我的用户对象的 conversation.access 范围 bean
public class UserEntity {
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "userEntity")
@JsonIgnore
private List<UserAuthorityEntity> userAuthorityEntities = new ArrayList<UserAuthorityEntity>();
}
- 在第一个请求上加载用户
- 在第二个请求中,我从列表中删除一个 UserAuthorityEntity 并合并用户
- 在第三个请求中,我从列表中删除另一个 UserAuthorityEntity 并合并用户
直到第二个请求一切正常并且一切都在数据库中正确持久化。
但是在第三个请求中我得到了错误
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [mypackage.common.account.UserAuthorityEntity#mypackage.common.account.UserAuthorityEntity$AuthoritiesEntityUserEntityPK@63f4adf]
at org.hibernate.internal.SessionFactoryImpl$1$1.handleEntityNotFound(SessionFactoryImpl.java:244)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:212)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:150)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1092)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1019)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:672)
at org.hibernate.type.EntityType.resolve(EntityType.java:490)
at org.hibernate.type.EntityType.replace(EntityType.java:354)
at org.hibernate.type.CollectionType.preserveSnapshot(CollectionType.java:558)
at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:532)
at org.hibernate.type.CollectionType.replace(CollectionType.java:660)
at org.hibernate.type.TypeHelper.replace(TypeHelper.java:177)
at org.hibernate.event.internal.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:372)
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:309)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:151)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:76)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:914)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:898)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:902)
at mypackage.dao.MainDao.merge(MainDao.java:105)
“AuthoritiesEntityUserEntityPK”表示他正在寻找我在第二个请求中删除的对象。
有什么想法有什么问题吗?