gpt4 book ai didi

java - 附加实体是否需要在 JPA 中合并?

转载 作者:太空狗 更新时间:2023-10-29 22:40:30 24 4
gpt4 key购买 nike

我永远不需要使用 EntityManager#merge() 是否正确,只要我只处理 attached 托管实体?换句话说,在 attached 托管实体上调用 merge() 没有效果?

或者在某些情况下合并会起到一定的作用?我发现这个名字暗示我可以用它来处理 OptimisticLockException... :)

编辑:简单来说,我对托管实体的理解是,在事务结束时对其属性/字段的修改会持久保存到数据库中。

最佳答案

规范指出:

If X is a managed entity, it is ignored by the merge operation, however, the merge operation is cascaded to entities referenced by relationships from X if these relationships have been annotated with the cascade element value cascade=MERGE or cascade=ALL annotation.

关于java - 附加实体是否需要在 JPA 中合并?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7387734/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com