Author: adamw
Date: 2009-06-05 08:25:08 -0400 (Fri, 05 Jun 2009)
New Revision: 16702
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
Log:
HHH-3939:
- not creating a join table when the association is not audited
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-06-05
12:09:49 UTC (rev 16701)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-06-05
12:25:08 UTC (rev 16702)
@@ -164,6 +164,19 @@
}
}
+ private boolean checkPropertiesAudited(Iterator<Property> properties,
ClassAuditingData auditingData) {
+ while (properties.hasNext()) {
+ Property property = properties.next();
+ String propertyName = property.getName();
+ PropertyAuditingData propertyAuditingData =
auditingData.getPropertyAuditingData(propertyName);
+ if (propertyAuditingData == null) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
@SuppressWarnings({"unchecked"})
private void createJoins(PersistentClass pc, Element parent, ClassAuditingData
auditingData) {
Iterator<Join> joins = pc.getJoinIterator();
@@ -174,6 +187,11 @@
while (joins.hasNext()) {
Join join = joins.next();
+ // Checking if all of the join properties are audited
+ if (!checkPropertiesAudited(join.getPropertyIterator(), auditingData)) {
+ continue;
+ }
+
// Determining the table name. If there is no entry in the dictionary, just
constructing the table name
// as if it was an entity (by appending/prepending configured strings).
String originalTableName = join.getTable().getName();
@@ -210,8 +228,10 @@
Join join = joins.next();
Element joinElement = entitiesJoins.get(entityName).get(join);
- addProperties(joinElement, join.getPropertyIterator(), currentMapper,
auditingData, entityName,
- xmlMappingData, firstPass);
+ if (joinElement != null) {
+ addProperties(joinElement, join.getPropertyIterator(), currentMapper,
auditingData, entityName,
+ xmlMappingData, firstPass);
+ }
}
}