[hibernate-dev] JPA Events

Steve Ebersole steve at hibernate.org
Mon Mar 19 11:32:19 EDT 2018


It is actually very unclear.  Look at the wording... "...update operations
to *entity* data...".  So clearly it boils down to your definition of
"entity data" and what is being updated, as Oliver mentions as well.  We
take the interpretation that since we are not updating the entity table
here, we do not fire the event (unless the entity is versioned, in which
case the change in the collection would cause a version increment and the
entity table to be updated as well).

In Hibernate, this would translate to a collection event - but of course
JPA has no such notion.  And the distinction is actually quite important
for supporting things like Envers, so it would need to be a VERY compelling
reason to change this behavior in Hibernate.

On Mon, Mar 19, 2018 at 9:55 AM Petar Tahchiev <paranoiabla at gmail.com>
wrote:

> Hi guys,
>
> I opened an issue in the JPA spec here yesterday:
>
> https://github.com/javaee/jpa-spec/issues/167
>
> because @PreUpdate and @PrePersist events are not fired when I save a
> collection on the owner. Since then, a discussion with Oliver Gierke from
> the SpringDATA team started and I wanted to know your opinion on this.
>
> Basically the question is: if you have Product with a Collection<String>
> attribute and you update the collection, shall @PreUpdate event be fired.
>
> As Oliver mentioned the JPA spec says:
> -------
> The PreUpdate and PostUpdate callbacks occur before and after the database
> update operations to entity data respectively.
> -------
>
> so to me it is obvious that when an attribute of the Product is changed
> then this means that @PreUpdate event for the Product must be fired.
>
> What do you think? Should I open a bug in Hibernate?
>
> --
> Regards, Petar!
> Karlovo, Bulgaria.
> ---
> Public PGP Key at:
> http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x19658550C3110611
> Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list