开发者

Hibernate: First cascade missing after server restart

开发者 https://www.devze.com 2023-02-19 09:21 出处:网络
When I update my entity I keep track of the authors with @PreUpdate und @PrePer开发者_StackOverflow社区sist and add an entry to my entity\'s authors history.

When I update my entity I keep track of the authors with @PreUpdate und @PrePer开发者_StackOverflow社区sist and add an entry to my entity's authors history.

When I initially start my application the first ever change will not be cascaded, thus my authors-reference table will not have a new author included. Any subsequent changes are correctly persisted / cascaded. The annotated methods are correctly called. Any ideas? This behaviour is reproducible.

@Column(nullable = false)
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<Author> authors = new ArrayList<Author>();

@PreUpdate
protected void onUpdate() {
   authors.add(new Author("update", ...));
}

@PrePersist
protected void onCreate() {
   authors.add(new Author("create", ...));
}

I'm using Hibernate 3.5.5 and the spring framework for EM injection.

0

精彩评论

暂无评论...
验证码 换一张
取 消