Hi,

That is possible. Do like this:

1. Turn off the ordinary audit fields by adding the following to
sculptor-generator.properties:
generate.auditable=false

2. Define the AuditRecord in your model.btdesign:

    Module audit {
        ValueObject AuditRecord {
            String entityName;
            Long entityId;
            Timestamp timestamp;
            String updatedBy;

            Repository AuditRecordRepository {
                save;
            }
        }
    }

3. Add the attached AuditRecordListener and AuditRecordRepositoryLocator to
your src/main/java (change package name)
http://old.nabble.com/file/p29374747/AuditRecordListener.java
AuditRecordListener.java 
http://old.nabble.com/file/p29374747/AuditRecordRepositoryLocator.java
AuditRecordRepositoryLocator.java 

4. And finally, redefine the generation template for JPA listeners, so that
your new AuditRecordListener is used. Add the following to
src/main/resources/templates/SpecialCases.xpt:

«AROUND templates::DomainObject::jpaEntityListenersAnnotation FOR
DomainObject -»
@javax.persistence.EntityListeners({
        «formatAnnotationParameters({
                getValidationEntityListener() != null, "", 
getValidationEntityListener() +
".class",
                true, "",
"org.fornax.cartridges.sculptor.examples.library.audit.domain.AuditRecordListener.class"
        })»})
«ENDAROUND»


Try that as a first step, then if you need to track changes of individual
fields you can define 
generate.fullAuditable=true
in sculptor-generator.properties
That will keep track of each change in the entity, including field name, old
value, and new value. That can be stored by the AuditRecordListener. Let us
know if you need help with that part.

/Patrik


Narich wrote:
> 
> Hello eveyrbody
> 
> I would like to use Fornax audit mecanisme , but in différent way; I want
> to save auditable attibutes(lastUpdated,lastUpdatedBy...) in other table
> on the database .
> 
> for example i will have an new entity (entity_audit) , that contains
> auditable attributes and other informations (filed_name, tab_name, user_id
> ....)
> 
> can i use Interceptor do this ?
> 
> thanks 
> 

-- 
View this message in context: 
http://old.nabble.com/Audit-in-a-separable-table-tp29356396s17564p29374747.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.


------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Fornax-developer mailing list
Fornax-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Reply via email to