openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Struberg (JIRA)" <>
Subject [jira] Commented: (OPENJPA-1873) EntityManager#merge sometimes passes wrong entity values to @PostLoad EntityListeners
Date Fri, 12 Nov 2010 16:42:13 GMT


Mark Struberg commented on OPENJPA-1873:

I'm very interested why OpenJPA currently loads the dirty fields from the database (in a manner
which in the logs looks like it's doing multiple database interactions!) instead only _loading_
the version (if present). 

Fact: a @PostLoad must get called after loading from the database. Thus I'd say that it needs
to get called even if entities only got loaded partly. But the spec also defines that the
_entity_ from the db needs to get posted. Currently we get a mix between old and new values
in @PostLoad which (I think we agree) is wrong.

Also quoting from the spec posted above:
"In the absence of Version columns there is no additional version checking done by the persistence
provider runtime during the merge operation."

I interpret is that in reverse it should be checked on #merge if an @Version is present.

> EntityManager#merge sometimes passes wrong entity values to @PostLoad EntityListeners

> --------------------------------------------------------------------------------------
>                 Key: OPENJPA-1873
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2
>            Reporter: Mark Struberg
>         Attachments: OPENJPA-1873-unittest.patch,
> I've tested this with the latest from branches/2.0.x.
> My entity has an @EntityListeners which observes the @PostLoad lifecycle event. This
listener stores the 'old' values from the database for later use (see
for the intention behind). All works well if the table has only a few rows. But if you add
more rows, OpenJPA tries to optimize the access and only loads the @Version field + the dirty
fields. In this case the merging seems to be wrong, because I get the NEW values from the
dirty fields instead of the original values from the database passed to my @PostLoad method.
> Did cost me a few grey hairs to track down the differences between the working and the
broken scenarios here ;) But finally I was able to creat a unit test showing the problem

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message