[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5911) Version number incremented even if all changes of the entity were reverted by an interceptor

Gail Badner (JIRA) noreply at atlassian.com
Thu Feb 17 20:22:05 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=40021#action_40021 ] 

Gail Badner commented on HHH-5911:
----------------------------------

I'm not sure when this will be fixed.

If you have a workaround, then please provide it here so others can see it.

Any ideas about a fix?

> Version number incremented even if all changes of the entity were reverted by an interceptor
> --------------------------------------------------------------------------------------------
>
>                 Key: HHH-5911
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5911
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.0-Final, 3.6.0
>         Environment: win xp, java 6
>            Reporter: Norbert Sándor
>         Attachments: testcase-hhh-5911.zip
>
>
> In our application we have a Hibernate interceptor which may revert all changes made to an entity in the onFlushDirty() method, based on various conditions. After doing so, our onFlushDirty() implementation returns true indicating that the currentState array has changed.
> It works as expected in most cases but we experience the following if all property values are reverted:
> - the entity is not updated in the database - as expected
> - the version number of the entity is still incremented - this means that the database and the entity will not be in sync after flush
> I investigated the problem and found the following code in DefaultFlushEntityEventListener.isVersionIncrementRequired():
> Code:
>    private boolean isVersionIncrementRequired(
>          FlushEntityEvent event,
>          EntityEntry entry,
>          EntityPersister persister,
>          int[] dirtyProperties
>    ) {
>       final boolean isVersionIncrementRequired = entry.getStatus()!=Status.DELETED && (
>             dirtyProperties==null ||
>             Versioning.isVersionIncrementRequired(
>                   dirtyProperties,
>                   event.hasDirtyCollection(),
>                   persister.getPropertyVersionability()
>                )
>          );
>       return isVersionIncrementRequired;
>    }
> In our case dirtyProperties is null (because all dirty properties were reverted by the interceptor), so isVersionIncrementRequired() will return true. It means that the version is incremented even if no properties were changed and no database update is performed when flushing.
> Thanks for your help in advance!
> Norbi

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list