I am using OpenJPA 1.2.3 in WebSphere 7.  I have an entity that I have added
an entity listener via annotation.  In the entity listener class, I have
defined PostPersist, PostUpdate, and PostRemove methods.

I am using a web service.  Within the web service lifecycle, there are two
different methods that deal with my entity object.  In one, I am just doing
a fetch by creating a query & invoking query.getSingleResult().  In the
other method, I am updating the object.  Both of these methods are causing
the lifecycle PostUpdate method to be invoked.  I believe that the second is
correct, but I'm not sure why PostUpdate is being called by the query.  My
understanding is that PostLoad only should be invoked.

The following is my stack trace from the invocation by the Query method
(AuditListener.updateCheck is my lifecycle PostUpdate method):

AuditListener.updateCheck(Object) line: 66      
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]       
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 60      
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 37  
Method.invoke(Object, Object...) line: 611      
BeanLifecycleCallbacks.makeCallback(Object, Object, int) line: 85       
LifecycleEventManager.makeCallbacks(Object, Object, ClassMetaData, int,
Collection) line: 340   
LifecycleEventManager.fireEvent(Object, Object, ClassMetaData, int) line:
302     
BrokerImpl.fireLifecycleEvent(Object, Object, ClassMetaData, int) line: 690     
StateManagerImpl.fireLifecycleEvent(int) line: 352      
StateManagerImpl.afterFlush(int) line: 1008     
BrokerImpl.flush(int) line: 2052        
BrokerImpl.flushSafe(int) line: 1927    
BrokerImpl.flush() line: 1698   
QueryImpl.isInMemory(int) line: 956     
QueryImpl.execute(int, Map) line: 838   
QueryImpl.execute(Map) line: 779        
DelegatingQuery.execute(Map) line: 525  
QueryImpl(QueryImpl).execute() line: 254        
QueryImpl(QueryImpl).getSingleResult() line: 317        

Should this be happening?  Is there a way I can prevent it?

Don


--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Lifecycle-listener-invoked-on-Query-tp7329975p7329975.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to