[英]When updating an ElementCollection does it trigger the @PostUpdate of the containing object?
I have an @ElementCollection Map<User, Long> permissions
in a class.我在 class 中有一个
@ElementCollection Map<User, Long> permissions
。
@ElementCollection
@CollectionTable(name = "als_permission", joinColumns = @JoinColumn(name = "File"))
@MapKeyJoinColumn(name = "User")
@Column(name = "Permission")
@JsonIgnore
private Map<User, Integer> permissions = new HashMap<>();
I made some changes on that collection only, and invoke repo.save(entity)
.我只对该集合进行了一些更改,并调用
repo.save(entity)
。 I see the record does get updated, but my @PostUpdate
handler which is defined in @EntityListeners
does not appear to be called.我看到记录确实得到了更新,但我在
@EntityListeners
中定义的@PostUpdate
处理程序似乎没有被调用。
Is there something I have to put to indicate it?有什么我必须指出的吗? I am thinking I may need to have some sort of
cascade
somewhere.我在想我可能需要在某个地方进行某种
cascade
。
Short Answer: No.简短的回答:没有。
I had the same issue came to the conclusion that this is not possible at the moment.我有同样的问题得出的结论是目前这是不可能的。 Mainly because intended or not implemented yet, see: https://github.com/eclipse-ee4j/jpa-api/issues/167
主要是因为打算或尚未实现,请参阅: https://github.com/eclipse-ee4j/jpa-api/issues/167
For the testing I created a repository to find any event I could consumer for the given purpose: https://github.com/HannesRakete/so-jpa-element-collection-events对于测试,我创建了一个存储库来查找我可以为给定目的使用的任何事件: https://github.com/HannesRakete/so-jpa-element-collection-events
Add a @Version for optimistic locking on the parent entity.添加 @Version 以对父实体进行乐观锁定。
Migrate to another association-type, see https://thorben-janssen.com/hibernate-tips-query-elementcollection/迁移到另一种关联类型,请参阅https://thorben-janssen.com/hibernate-tips-query-elementcollection/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.