3 Replies Latest reply on Oct 12, 2011 5:16 AM by Adam Warski

    Evers and legacy applications

    Aymen Ben Hmida Newbie

      hi all,

       

      we have a legacy application using hibernate xml configuration and we would give a try to envers auditing.  Using envers with its default configuration works perfectly. But we need some customization to store data of the use who have done the changes to data in the DB. We created the persistence.xml file like this

       

      <persistence-unit name="manager" transaction-type="RESOURCE_LOCAL">

                 <provider>org.hibernate.ejb.HibernatePersistence</provider>

                          <properties>

                                    <property name="hibernate.hbm2ddl.auto" value="update" />

                                    <property name="hibernate.show_sql" value="true" />

                                    <property name="hibernate.format_sql" value="true" />

                                    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />

       

       

                                    <property name="hibernate.ejb.event.post-insert"

                                              value="com.axones.audit.lestener.HistoryEntityListener" />

                                    <property name="hibernate.ejb.event.post-update"

                                              value="com.axones.audit.lestener.HistoryEntityListener" />

                                    <property name="hibernate.ejb.event.post-delete"

                                              value="com.axones.audit.lestener.HistoryEntityListener" />

                                    <property name="hibernate.ejb.event.pre-collection-update"

                                              value="com.axones.audit.lestener.HistoryEntityListener" />

                                    <property name="hibernate.ejb.event.pre-collection-remove"

                                              value="com.axones.audit.lestener.HistoryEntityListener" />

                                    <property name="hibernate.ejb.event.post-collection-recreate"

                                              value="com.axones.audit.lestener.HistoryEntityListener" />

                                    <property name="org.hibernate.envers.audit_table_suffix"

                                              value="_AUDITABLE" />

       

       

                                    <property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>

       

       

                                    <property name="hibernate.bytecode.use_reflection_optimizer"

                                              value="false" />

                                    <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />

                                    <property name="hibernate.connection.password" value="password" />

                                    <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/mydb" />

                                    <property name="hibernate.connection.username" value="root" />

                                    <property name="hibernate.search.autoregister_listeners"

                                              value="false" />

       

                          </properties>

                </persistence-unit>

      and in hibernate.cfg.xml we keep the declaration of the entities either the xml configured or the annotation configured, but this does seem to work, envers stil using its default config revinfo, _aud tables.....

      how can i get the configuration so that envers uses the new listener and the new entity?