Hello, I just found this project and I would love to use it for our application. However we are unable to use the annotation method because some of our objects are reused across multiple services, and auditing is only required for some of them. I know there was a jira request opened, but it doesn't seem like it was ever assigned. Are there any future plans to offer an hbm or some other xml mapping configuration?

well, putting the @Audited annotations doesn't cause the entities to be automatically audited - for that to hapeen you need two additional things:

1) envers jar in the classpath

2) listeners added to the hibernate configuration file

Without that @Audited doesn't have any effect. As this is an annotation, the envers jar doesn't even have to be on the classpath for the entity to be used - the annotations are then completely ingored by java.

As for the xml configuration, there are no plans yet, but it wouldn't be hard to add such a feature, so if you'd like to contribute, I'll be happy to help!

i am following the cml configuration issue for a long time and would be happy to have it ! So I will give it a try to implement it. A few hints would be really nice ! After reading the other posts in the forum and a bit of source my approach is the following:

-> the starting point is AuditConfiguration class (there the audit meta data is created)

-> because the xml configuration doesn't support something like @Audited we need a second configuration (for example a custom xml file) to define the the @Audited information

-> is there a way to read the persistence data envers needs from the entity.hbm.xml files, load the aditional custom xml file with the version information, and combine both to get envers working ?

first, sorry for the late reply - vacation, devoxx and then lots of work kept me away from the forum And thanks for the interest - it would be great to have a contributor for that feature!

I think the best approach is to modularize a bit and allow the audit configuration reading code to be pluggable & configurable via a properties entry.

If you look in EntitiesConfigurator, the point at which annotations are read is AnnotationsMetadataReader (line 77). So you would have to subsitute that for your implementation. The AnnotationsMetadataReader is a class which takes the entity class and returns a description of the audit-related annotations that are on it. Feel free to refactor whatever is needed to achieve the functionality.

during the last weeks i had time to work on the topic and got one step further I think. I first describe the goal from my point of view and then tell you how far I got up to now:

Overall Goal:

Extend the Hibernate Xml Configuration possibilities so that you can define the Envers functionality with it. Interpret and integrate the Envers-Xml-Configuration so that Envers works with Xml configuration.

Current Goal:

Write an self defined Xml configuration file which defines the Envers-Configuration. Integrate it in the code so that you can have an Xml configured Hibernate Project and use hibernate by providing the extra xml configuration.

What is working so far:

By now I implemented a simple Xml configuration for the Envers part, use it with a simple XML configured Hibernate project and it seems to work. It's still a prototype status and no inheritance is working, this i want to do as the next step !

Questions:

At first a short explanation: I took the integration point you mentioned, the AnnotationMetadataReader. I wrote an XmlMetadataReader which reads an Xml-File as a configuration. From that point I look what you did in the annotaion reader try more or less copy the functionality.

1: For what you need the ModificationStore ? It just cann be the default value or null.

2: For the possible Envers-Annotations i will code Classes which implement the annotations and fill them with the values from the Xml configuration file.

3: For the inheritance part: Do you check all superclasses, check if they have audited properties and then add them ? I need a bit more explanation how the inheritance exactly works !

What would be the best way that you can have a look at the code ? Check out the hibernate project and create a branch ? Any other idea ?

thank you for the answers ! I have another question. As the entry point you gave me the AnnotationsMetadataReader (line 77). Now I am trying handle the RevisonEntity in the Xml Configuration. For that I think I have to look and rewrite the RevisonInfoConfiguration class (which is created by the AuditConfiguration). I just want to know if I am on the right way ?

i think did quite well. I just tried to reimplement your configuration by getting the information out of an XML file. I did the following up to now:

- definition of an XSD which allows the Envers Configuration in Xml

- inserted a global variable which allows to switch between the Xml and the Annotation configuration (the Xml file can be set in another variable)

- reimplemented the configuration on Xml basis

- adjusted the Ant-Task for DB Schema generation so that its working with Xml configuration

- wrote Tests for checking the some functionality: inheritance, components, self defined revision and revision listeners, relations, envers queries (not much so far, just basics)

I still have some questions questions:

- for what exactly you have the Method AuditPropertiesReader.doGetDeclaredAuditedSuperclasses ? It is just doing something if a class is audited and it has values in the auditParents.

- in which case the AuditPropertiesReader.computeAuditConfiguration method is important ? If the the class is not audited it checks if the class is in the declaredSuperclasses, if so it returns the Audit Annotation from

PersistenPropertiesSource

As the next step i will get the code from github and integrate my code. Do you have branches vor every version ? I need to use Hibernate 3.9 in our project, so it has to run there also.

If i checked it in will you take a look at the code ?

Did you programm tests which I can adjust so that they can run against Xml configuration ?

* doGetDeclaredAuditedSuperclasses: that's to support auditParents. There are cases where you have a superclass and two subclasses, one of which is audited. If you then want to audit the parent of that class as well, but do not audit anything in the second entity, you need the auditParents. So you can specify on an audited entity which superclasses should be audited as well.

* doGetDeclaredAuditedSuperclasses - I can't find that method?

Hibernate 3.9? You probably mean 3.6?

If you check it in I will of course take a look, though I can't make promises on when.

I did that but i have to integrate my work into the repo (started a few month ago without clonig the repo). I hope will finish the integration of my work this week and then we can work togehter on the basis of my work.

The building of the complete hibernate project doesn't work on my computer, but the envers-sub project works, that should be enough I think.

I made a branch: ENVERS-XML-CONFIGURATION. The points where I jumped in the code are the ones Adam told me. The XSD I made for the XML configuration is under src/main/resources (everything in the envers sub project). The JAXB generated Code to access the Xml configuration I put under src\main\java\org\hibernate\envers\configuration\metadata\xml\jaxb. With git you will see what i have done so far. Take a look and ask if you have questions.

The next weeks it looks good so that I will have some time to work on the project again. I want to programm some test cases to check the functionallity whick works right now.