-
1. Re: Annotation / persistence.xml question
dave_lilley May 15, 2009 4:22 PM (in response to dave_lilley)BTW, if we disable auditing, the JMS listener works.
-
2. Re: Annotation / persistence.xml question
adamw May 16, 2009 5:09 AM (in response to dave_lilley)Hello,
well, you should specify all listeners in persistence.xml. For example, if you are using Envers and EJB3, then if you want the @PostX and @PreX callback to work, you have to specify both the EJB3 listener and Envers listener; in post-insert, that would be:org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener
What exactly are the "JMS listeners"?
Adam -
3. Re: Annotation / persistence.xml question
dave_lilley May 18, 2009 12:12 PM (in response to dave_lilley)My bad. I should have put JMS listeners in quotes.
Or better yet, what I should have said is that we have created a custom class that is annotated on @EntityListeners. The custom class has methods annotated with @PostPersist, @PostRemove, and @PostUpdate respectively.
When triggered, the methods raises events that are handled by an observer. The observer takes the object and message and publishes them to a JMS topic, which is subscribed to by a Flex Client.
When I put the Envers event listeners in persistence.xml, the class on the @EntityListeners annotation is not called. -
4. Re: Annotation / persistence.xml question
dave_lilley May 18, 2009 1:01 PM (in response to dave_lilley)Note: When I changed our entity listener class to an event listener, added code to exclude audit entities, and put the new listener in persistence.xml, both listeners worked.
My question now is, why does the audit event listener seem to short circuit an entity listener specified on an entity via an annotation. -
5. Re: Annotation / persistence.xml question
dave_lilley May 18, 2009 1:03 PM (in response to dave_lilley)...if needed I could produce an test case and submit a jira.
-
6. Re: Annotation / persistence.xml question
adamw May 19, 2009 2:32 AM (in response to dave_lilley)Hello,
did you include the default listeners in your persistence.xml?<property name="hibernate.ejb.event.post-insert" value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.post-update" value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.post-delete" value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener" />
Also, what do you mean by "adding code to exclude audit entities"? :)
Adam -
7. Re: Annotation / persistence.xml question
dave_lilley May 19, 2009 3:34 PM (in response to dave_lilley)We are using SEAM, so as I understand it, the EJB3 listener isn't required.
I had the AuditEventListener in persistence.xml. The problem is that when I add the AuditEventListener in persistence.xml, the @EntityListeners specified on the annotation no longer works. -
8. Re: Annotation / persistence.xml question
adamw May 20, 2009 2:12 AM (in response to dave_lilley)Hello,
well, but you are using JPA (as I understand), which is a part of EJB3, so you need the EJB3 listeners for the @EntityListneres/@PostX callbacks to work.
Adam -
9. Re: Annotation / persistence.xml question
dave_lilley May 20, 2009 9:14 AM (in response to dave_lilley)I will re-read the documentation, but we are using SEAM annotations, and it has worked until now.
-
10. Re: Annotation / persistence.xml question
adamw May 20, 2009 11:21 AM (in response to dave_lilley)Hello,
you lost me :). What is the package of the @EntityListeners annotation you use? And what "seam annotations" regarding entities do you use?
Did you try configuring the listeners including the EJB3 and Envers one?
Adam -
11. Re: Annotation / persistence.xml question
dave_lilley May 20, 2009 12:41 PM (in response to dave_lilley)Adam,
You were right. Thanks for your help.
Dave -
12. Re: Annotation / persistence.xml question
dave_lilley May 20, 2009 12:45 PM (in response to dave_lilley)"adamw" wrote:
Hello,
you lost me :). What is the package of the @EntityListeners annotation you use? And what "seam annotations" regarding entities do you use?
Did you try configuring the listeners including the EJB3 and Envers one?
Adam
On our abstract entity is the root for all of our entities, we have an entity listener from javax.persistence.EntityListeners.
When I added the EJB3 event listeners in persistence.xml, the entity listeners worked.
Thanks again,
Dave