-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate + envers + Tomcat
PostPosted: Wed Jun 17, 2009 5:01 pm 
Beginner
Beginner

Joined: Fri Nov 11, 2005 4:35 pm
Posts: 23
Hi,

I'm testing with hibernate envers.

I'm using a tomcat 6.0.18 with the following libs:
- hibernate Annotation 3.4.0.ga
- hibernate core 3.3.0.SP1
- hibenate envers 1.2.1.ga

I added to following lines to my hibernate.cfg.xml
hibernate.ejb.event.post-insert org.hibernate.envers.event.AuditEventListener
hibernate.ejb.event.post-update org.hibernate.envers.event.AuditEventListener
hibernate.ejb.event.post-delete org.hibernate.envers.event.AuditEventListener
hibernate.ejb.event.pre-collection-update org.hibernate.envers.event.AuditEventListener
hibernate.ejb.event.pre-collection-remove org.hibernate.envers.event.AuditEventListener
hibernate.ejb.event.post-collection-recreate org.hibernate.envers.event.AuditEventListener
org.jboss.envers.warnOnUnsupportedTypes true

I also added the following annotations to my class
@Entity
@Audited
@Table(name = "time_roundingparameter")
public class TimeRoundingParameter{
....
}

But nothing happens.
When I insert a record the time_roundingparameter table is filled.
The time_roundingparameter_aud and revinfo stays empty.
No exeception is thrown!

Does anyone has any idee what could be wrong?

Thanks in advance,
Pieter


Top
 Profile  
 
 Post subject: Re: Hibernate + envers + Tomcat
PostPosted: Thu Jun 18, 2009 7:08 am 
Beginner
Beginner

Joined: Fri Nov 11, 2005 4:35 pm
Posts: 23
I found it!

The hibernate.cfg.xml parameters doesn't work, so you can remove them.

In order to make you hibernate aware of the listeners you can add them directly to the configuration.

Below the code:

AnnotationConfiguration configuration = new AnnotationConfiguration();
AuditEventListener auditEventListener = new AuditEventListener();
configuration.getEventListeners().setPostInsertEventListeners(new PostInsertEventListener[]{auditEventListener});
configuration.getEventListeners().setPostUpdateEventListeners(new PostUpdateEventListener[]{auditEventListener});
configuration.getEventListeners().setPostDeleteEventListeners(new PostDeleteEventListener[]{auditEventListener});
sessionFactory = configuration.buildSessionFactory();

Session s = sessionFactory.openSession();
....

Good luck,
Pieter Pareit
http://www.art-gallery.be


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.