Hibernate: First cascade missing after server restart
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.
精彩评论