You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Jeff Oh (JIRA)" <ji...@apache.org> on 2014/03/06 06:14:45 UTC

[jira] [Comment Edited] (OPENJPA-2479) LifecycleListener invocation order inconsistent when listeners are added to the EntityManagerFactory

    [ https://issues.apache.org/jira/browse/OPENJPA-2479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13922019#comment-13922019 ] 

Jeff Oh edited comment on OPENJPA-2479 at 3/6/14 5:14 AM:
----------------------------------------------------------

Patch file which fixes OPENJPA-2479 attached.


was (Author: jeffoh):
Patch file which fixes OPENJPA-2479

> LifecycleListener invocation order inconsistent when listeners are added to the EntityManagerFactory
> ----------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2479
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2479
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.3.0
>            Reporter: Jeff Oh
>              Labels: easyfix, patch
>             Fix For: 2.3.1
>
>         Attachments: OPENJPA-2479-trunk.patch
>
>
> The EntityManagerFactory contains the method addLifecycleListener().  While the EntityManagerFactory never invokes these listeners itself, it does add them to any EntityManagers created by the factory.
> Unfortunately, the EntityManagerFactory stores the listeners added to the factory in a java.util.HashMap.  As a result, the order that the listeners were added is lost.  If there is a dependency in the listener order then it is impossible to guarantee the order in which listeners are invoked.  As an example, if listener one modifies an object in the beforePersist() handler, and listener two writes audit records describing changes in a separate beforePersist() handler, then it is important to be to control the order in which the listeners are executed.
> The attached patch and unit test replaces the HashMap inside of AbstractBrokerFactory with a LinkedHashMap so that listeners are invoked in predictable order.



--
This message was sent by Atlassian JIRA
(v6.2#6252)