-->
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.  [ 12 posts ] 
Author Message
 Post subject: Envers, hibernate.cfg.xml
PostPosted: Sat Aug 08, 2009 6:26 pm 
Beginner
Beginner

Joined: Thu Feb 21, 2008 3:31 pm
Posts: 34
Hi all,

I have had Envers working well with Hibernate configured as a JPA provider through persistence.xml; however, I wanted to fully leverage Hibernate and decided to setup hibernate through hibernate.cfg.xml.

Even though I still have Envers configured in hibernate.cfg.xml, Envers does not appear to be setup to listen for any of the events hibernate fires. I haven't seen much documentation on this, but it hints at hibernate.cfg.xml:

http://www.jboss.org/files/envers/docs/ ... tml#d0e221


With those Event Listeners added in hibernate.cfg.xml, I don't see any of the Audit Tables being created as they once were with my old configuration using JPA.


Has anyone had any luck with Envers and Hibernate configured through hibernate.cfg.xml?


Thanks,
Walter


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Sun Oct 04, 2009 10:45 am 
Newbie

Joined: Sat May 19, 2007 10:15 am
Posts: 2
I have exactly the same problem. Don't know how to configure envers in the hibernate.cfg.xml
I suspect a problem of compatibility between hibernate stack and envers.
anyone has resolved this problem ?


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Sun Oct 04, 2009 4:27 pm 
Beginner
Beginner

Joined: Thu Feb 21, 2008 3:31 pm
Posts: 34
I ended up just using the JPA configuration since it integrates so nicely with Seam. Even though I don't anticipate ever switching to another ORM package, I'm doing things the JPA way.

Walter


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Wed Nov 11, 2009 3:37 am 
Newbie

Joined: Wed Nov 11, 2009 3:34 am
Posts: 2
I'm having the same problem..
Does anyone know how to configure envers in hibernate.cfg.xml?

thanks


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Thu Nov 12, 2009 3:32 am 
Newbie

Joined: Wed Nov 11, 2009 3:34 am
Posts: 2
It worked with this:

<hibernate-configuration>
<session-factory>
...
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-insert"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-update"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-delete"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-update"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-remove"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-collection-recreate"/>
...
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Thu Nov 12, 2009 8:03 pm 
Beginner
Beginner

Joined: Thu Feb 21, 2008 3:31 pm
Posts: 34
Hi,

Thanks for your reply, that looked rather obvious. I thought I had tried that a while back and didn't see the audit tables get created, but perhaps I didn't have it setup properly.

Dumb question, since the Hibernate Session extends the JPA entity manager by providing additional functionality, can you still make use of JBoss Seam components that use the entity manager? You need to pass in a reference of the entity manager to those components.


Walter


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Thu Jun 24, 2010 8:24 am 
Newbie

Joined: Wed Jun 23, 2010 7:23 am
Posts: 8
hi,

What was your hibernate and envers configuration:

I have :


<listener class="org.hibernate.envers.event.AuditEventListener" type="post-insert"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-update"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-delete"/>

But i get this exception:
Code:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'session-factory' defined in class path resource [spring-config.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: java.lang.NoSuchMethodException: org.hibernate.cfg.Configuration.getReflectionManager()
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)



There is no such method getreflectionManager in Configuration class. I just dont undersatnd even though my envers is the first ever version 1.0.0 it is not able to work with hibernate 3.2.5


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Mon Jun 28, 2010 8:00 am 
Newbie

Joined: Wed Jun 23, 2010 7:23 am
Posts: 8
ok i solved the error i posted above Now i am havimng the same exact error as the OP and rafaelco. though i tried different forms of event lsiteners and still the same error.

I tried in hiberante.cfg.xml:
Code:
<event type="post-insert">
       <listener
       class="org.hibernate.envers.event.AuditEventListener" />
       </event>
        <event type="post-update">
       <listener
       class="org.hibernate.envers.event.AuditEventListener" />
       </event>
      
       <event type="post-delete">
       <listener
       class="org.hibernate.envers.event.AuditEventListener" />
       </event> -->
      
       <!-- needed to update the Eclipse Hibernate 3.0 dtd in order to recognise these collection events
       <event type="pre-collection-update">
       <listener
       class="org.hibernate.envers.event.AuditEventListener" />
       </event>
      
       <event type="post-collection-recreate">
       <listener
       class="org.hibernate.envers.event.AuditEventListener" />
       </event>
      
       <event type="pre-collection-remove">
       <listener
       class="org.hibernate.envers.event.AuditEventListener" />
       </event>


I tried in hibnernate.cfg.xml after removing the above ones:
Code:
         <listener class="org.hibernate.envers.event.AuditEventListener" type="post-insert"/>
          <listener class="org.hibernate.envers.event.AuditEventListener" type="post-update"/>
          <listener class="org.hibernate.envers.event.AuditEventListener" type="post-delete"/>
            <listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-update"/>
          <listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-remove"/>
          <listener class="org.hibernate.envers.event.AuditEventListener" type="post-collection-recreate"/>



And also tried in sprin-config.xml becuase my sessionfactory is made in spring-config.xml:
Code:
<bean name="session-factory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
          p:configLocation="classpath:hibernate.cfg.xml">
           <property name="eventListeners">
            <map>
                <entry key="post-insert" value-ref="enversEventListener"/>
                <entry key="post-update" value-ref="enversEventListener"/>
                <entry key="post-delete" value-ref="enversEventListener"/>
                <entry key="post-collection-recreate" value-ref="enversEventListener"/>
                <entry key="pre-collection-remove" value-ref="enversEventListener"/>
                <entry key="pre-collection-update" value-ref="enversEventListener"/>
            </map>
        </property>
      <!--  <property name="entityInterceptor">
          <bean class="com.illuminatics.losssharing.interceptor.AuditTrailInterceptor"/>
        </property>-->
        
   </bean>
   <bean id="enversEventListener" class="org.hibernate.envers.event.AuditEventListener" />



i am still stuck that my envers does not fill the _aud tables and they remain empty. The original update goes through fine. My application is working fine but the history is not created in revinfo table Nor the _aud table.

I will appreciate if some one has gone through this issue and was able to solve this

Thanks in advance.

Syed


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Mon Jan 10, 2011 7:27 pm 
Newbie

Joined: Sun Jan 09, 2011 6:51 pm
Posts: 2
Got exactly the same problem. I can see REVINFO table updated with new revision but none of the _AUD tables are inserted/updated. I was able to make it working using EntityManger/persisted.xml thou.
Any solution to make it working with hibernate.config.xml ???


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Mon Jan 10, 2011 8:20 pm 
Beginner
Beginner

Joined: Thu Feb 21, 2008 3:31 pm
Posts: 34
I don't believe so, it has been a while ... I remember looking at the source to see how to set it up but I don't believe it supported that configuration then. However, much has changed with Hibernate Envers these days.


Walter


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Wed Mar 02, 2011 1:25 pm 
Newbie

Joined: Wed Mar 02, 2011 1:20 pm
Posts: 1
Was there ever a definitive answer to this ?
Im using hibernate.cfg.xml and envers seems to totally ignore it ? no _AUD tables are created ?


Top
 Profile  
 
 Post subject: Re: Envers, hibernate.cfg.xml
PostPosted: Wed Mar 02, 2011 1:28 pm 
Beginner
Beginner

Joined: Thu Feb 21, 2008 3:31 pm
Posts: 34
The definitive answer is to use persistence.xml, JPA. I haven't combed through the source to see if it was ever supported or if a JIRA was ever filed.

I am using an Object Database to learn something new, so I haven't raised a JIRA or checked if there was one.

If you post a JIRA, Emmanuel or another developer will certainly get to it.


Walter


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 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.