// First pass
for ( Map.Entry<PersistentClass, ClassAuditingData> pcDatasEntry : classesAuditingData.getAllClassAuditedData() ) {
final PersistentClass pc = pcDatasEntry.getKey();
final ClassAuditingData auditData = pcDatasEntry.getValue();
final EntityXmlMappingData xmlMappingData = new EntityXmlMappingData();
if ( auditData.isAudited() ) {
if ( !StringTools.isEmpty( auditData.getAuditTable().value() ) ) {
verEntCfg.addCustomAuditTableName( pc.getEntityName(), auditData.getAuditTable().value() );
}
auditMetaGen.generateFirstPass( pc, auditData, xmlMappingData, true );
}
else {
auditMetaGen.generateFirstPass( pc, auditData, xmlMappingData, false );
}
xmlMappings.put( pc, xmlMappingData );
}
// Second pass
for ( Map.Entry<PersistentClass, ClassAuditingData> pcDatasEntry : classesAuditingData.getAllClassAuditedData() ) {
final EntityXmlMappingData xmlMappingData = xmlMappings.get( pcDatasEntry.getKey() );
if ( pcDatasEntry.getValue().isAudited() ) {
auditMetaGen.generateSecondPass( pcDatasEntry.getKey(), pcDatasEntry.getValue(), xmlMappingData );
try {
cfg.addDocument( writer.write( xmlMappingData.getMainXmlMapping() ) );
//writeDocument(xmlMappingData.getMainXmlMapping());
for ( Document additionalMapping : xmlMappingData.getAdditionalXmlMappings() ) {
cfg.addDocument( writer.write( additionalMapping ) );
//writeDocument(additionalMapping);
}
}
catch (DocumentException e) {