-->
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: Audit: define classes and events to be audited
PostPosted: Mon Sep 21, 2009 11:07 am 
Newbie

Joined: Mon Sep 21, 2009 10:28 am
Posts: 2
Hi friends.
I need to Audit several classes and to say to hibernate that the class TEST1 need to audit when its INSERT, but the TEST2 need to audit when INSERT AND UPDATE.
When in the HIBERNATE file I set the following source all is ok and the hibernate to audit all (insert, update, delete) of Test1 and Test2:

<listener type="pre-delete" class="auditar.HibernateAuditLogListener"/>
<listener type="pre-update" class="auditar.HibernateAuditLogListener"/>
<listener type="pre-insert" class="auditar.HibernateAuditLogListener"/>
<listener type="pre-load" class="auditar.HibernateAuditLogListener"/>

but I need to divide the auditing (I don't need to audit all), so that I configured the HIBERNATE whit the next source .

It is my HIBERNATE.CFG.XML :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@HOST:1521:SHEMA</property>
<property name="hibernate.connection.username">USER</property>
<property name="hibernate.connection.password">PASSWORD</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>

<!-- Audit class -->
<mapping resource="modelo/AuditTrail.hbm.xml"/>
<!-- Class for auditing -->
<mapping resource="modelo/Test1.hbm.xml"/>
<mapping resource="modelo/Test2.hbm.xml"/>

<!-- Listener IT IS THE ERROR -->
<entity class="models.Test">
<entity-listeners>
<entity-listener class="audit.HibernateAuditLogListener">
<pre-insert method-name="onPreInsert"/>
</entity-listener>
</entity-listeners>
</entity>

<entity class="models.Test2">
<entity-listeners>
<entity-listener class="audit.HibernateAuditLogListener">
<pre-insert method-name="onPreInsert"/>
<pre-insert method-name="onPreUpdate"/>
</entity-listener>
</entity-listeners>
</entity>
<!-- END LISTENER -->

</session-factory>
</hibernate-configuration>


After run my project I get the following error message

Caused by: org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1487)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at conexion.HibSession.<clinit>(HibSession.java:22)
... 81 more
Caused by: org.xml.sax.SAXParseException: Element type "entity" must be declared.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)

I need to know how to do that auditing because I need so.

Thanks.
God Bless you.
Angel


Top
 Profile  
 
 Post subject: Re: Audit: define classes and events to be audited
PostPosted: Tue Sep 22, 2009 7:00 pm 
Newbie

Joined: Mon Sep 21, 2009 10:28 am
Posts: 2
Topic resolved.
We must create our classes like implementation of Auditable Class.
If you need more information write me.
Bye


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.