Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 26369 invoked from network); 11 Aug 2009 15:19:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Aug 2009 15:19:49 -0000 Received: (qmail 12083 invoked by uid 500); 11 Aug 2009 15:19:55 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 12012 invoked by uid 500); 11 Aug 2009 15:19:55 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 12002 invoked by uid 99); 11 Aug 2009 15:19:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Aug 2009 15:19:55 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists+1214986160035-208411@n2.nabble.com designates 216.139.236.80 as permitted sender) Received: from [216.139.236.80] (HELO jim.nabble.com) (216.139.236.80) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Aug 2009 15:19:45 +0000 Received: from jim ([127.0.0.1]) by jim.nabble.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 11 Aug 2009 10:19:24 -0500 Date: Tue, 11 Aug 2009 10:19:24 -0500 (CDT) From: illhan To: users@openjpa.apache.org Message-ID: <1250003964248-3424516.post@n2.nabble.com> In-Reply-To: <72c1350f0908110651k6008448bv4b814dacf7eb8392@mail.gmail.com> References: <1249548280726-3397042.post@n2.nabble.com> <1249584810473-3400138.post@n2.nabble.com> <1249883948417-3415530.post@n2.nabble.com> <1249913525421-3417396.post@n2.nabble.com> <1249956335810-3421303.post@n2.nabble.com> <72c1350f0908110651k6008448bv4b814dacf7eb8392@mail.gmail.com> Subject: Re: how to use openjpa event listener ? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: quzheng911@yahoo.com.cn X-OriginalArrivalTime: 11 Aug 2009 15:19:24.0248 (UTC) FILETIME=[1BCFFD80:01CA1A97] X-Virus-Checked: Checked by ClamAV on apache.org hi Rick, Because of the audit logging,I used the openJPA LifeCycleListener(maybe other openjpa listerners) for audit logging. I have try to record the audit logging by JPA lifecycle callbacks,but in the callbacks method's I can not get the old state,I only get the new method. The document http://webspherepersistence.blogspot.com/2009/01/auditing-with-openjpa.html http://webspherepersistence.blogspot.com/2009/01/auditing-with-openjpa.html shows one method to record audit logging,but the audit method must be added in my all entites ,it is too complex for developers. in my opinion,the openJPA LifeCycleListener maybe the best way to reduse the developers workload,if it can be used here.I can use event descriptor in eclipselink(toplink),I only to register the event descriptor in persistence.xml.So I would like to found the similar way in openJPA environment. Thanks Rick. illhan Michael Dick wrote: > > Hi Illhan, > The method you want to use is part of OpenJPA's SPI layer, and isn't > intended to be used by most applications. As a result the interface may be > a > bit more fluid than our 'normal' API methods. > > Could you elaborate on why you want to add a LifeCycleListener? We might > be > able to suggest an alternative that accomplishes the same goal.. > > Best Regards, > -mike > > On Mon, Aug 10, 2009 at 9:05 PM, illhan wrote: > >> >> hi Rick, >> You means the JPA lifecycle Callbacks,But I want to know the openjpa's >> listener,in package org.apache.openjpa.event,the interface >> LifecycleListener >> and the class LifecycleEvents. >> From the javadoc,the LifecycleListener can be registered by the method >> addLifecycleListener(Object listener, Class... classes) from class >> org.apache.openjpa.persistence.EntityManagerImpl,but in JEE container the >> EntityManager is inited by the container itself.How can I registere the >> LifecycleListener and process the LifecycleEvents.I have reviewed the >> openjpa user's guide,but no part can be found there. >> Thanks Rick. >> illhan >> >> Rick Curtis wrote: >> > >> > Illhan - >> > >> > Did you read the section in the user manual detailing the usage of >> > Lifecycle Callbacks [1]? >> > >> > -Rick >> > >> > [1] >> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#jpa_overview_pc_callbacks >> > >> > >> > illhan wrote: >> >> >> >> hi Rick, >> >> The EntityManager and the EntityManagerFactory are initializated by >> the >> >> JEE contianer.I think the LifecycleListener could be set in >> >> persistent.xml,not only used by java code. >> >> Thanks Rick. >> >> >> >> illhan >> >> >> >> Rick Curtis wrote: >> >>> >> >>> Illhan - >> >>> In your application initialization I believe you could do something >> like >> >>> this to get a reference to the EntityManagerFactory.... >> >>> >> >>> OpenJPAEntityManager oem = OpenJPAPersistence.cast(em); >> >>> OpenJPAEntityManagerFactory oemf = >> >>> OpenJPAPersistence.cast(oem.getEntityManagerFactory()); >> >>> >> >>> - Rick >> >>> >> >>> illhan wrote: >> >>>> >> >>>> In the javadoc there are many event and listener.I want to use the >> >>>> event and the listener in jee enviroment,the emf.add**Listener() >> method >> >>>> can't not called because in jee enviroment the entitymanagerfacetory >> is >> >>>> created by jee contianer.i only use ejb3 injection in my session >> bean >> >>>> use @PersistenceContext >> >>>> private EntityManager em; >> >>>> so i don't know how to register the Listener(such as >> LifecycleListener) >> >>>> in JEE enviroment. >> >>>> >> >>>> illhan >> >>>> >> >>> >> >>> >> >> >> >> >> > >> > >> >> -- >> View this message in context: >> http://n2.nabble.com/how-to-use-openjpa-event-listener---tp3397042p3421303.html >> Sent from the OpenJPA Users mailing list archive at Nabble.com. >> > > -- View this message in context: http://n2.nabble.com/how-to-use-openjpa-event-listener---tp3397042p3424516.html Sent from the OpenJPA Users mailing list archive at Nabble.com.