hi Kevin,
I know i can cast the  EntityManager to OpenJPAEntityManagerSPI.In jee
environment,the EntityManager usally be injected in session bean(ejb3).If i
cast the EntityManager to OpenJPAEntityManagerSPI in session beans,should I
register the cast the type in my all sesson beans?
In my opinion I can regiester LifeCycleListener in the application init
phase,not in java code.I wish to use the LifeCycleListener in the config
files.
Thanks Kevin

illhan


Kevin Sutter wrote:
> 
> I agree with Mike that the methods you want to use are part of the OpenJPA
> SPI layer and, thus, are subject to change.  It would be good to
> understand
> your interest in these SPI's.  But, ...
> 
> Even in a container-managed environment, you have access to the
> EntityManager.  You could cast the EntityManager to
> OpenJPAEntityManagerSPI
> and have access to these methods.
> 
> Kevin
> 
> On Tue, Aug 11, 2009 at 8:51 AM, Michael Dick
> <[email protected]>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 <[email protected]> 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---tp3397042p3424586.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to