HHH-3939:

- not creating a join table when the association is not audited

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16702 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Adam Warski 2009-06-05 12:25:08 +00:00
parent 4097832958
commit d14805e920
1 changed files with 22 additions and 2 deletions

View File

@ -164,6 +164,19 @@ public final class AuditMetadataGenerator {
}
}
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 @@ public final class AuditMetadataGenerator {
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 @@ public final class AuditMetadataGenerator {
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);
}
}
}