From 096437dec2b81b2434435c602427d8ed2ffc60e5 Mon Sep 17 00:00:00 2001 From: Adam Warski Date: Wed, 25 Nov 2009 08:35:22 +0000 Subject: [PATCH] HHH-4608: - options to specify default schema/catalog name for audit tables git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18059 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../metadata/AuditMetadataGenerator.java | 16 ++++++++-------- .../metadata/CollectionMetadataGenerator.java | 6 ++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java b/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java index 76cd661ef2..2c11c03fbf 100644 --- a/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java +++ b/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java @@ -177,9 +177,9 @@ public final class AuditMetadataGenerator { return true; } - private String getSchema(AuditTable auditTable, Table table) { + protected String getSchema(String schemaFromAnnotation, Table table) { // Get the schema from the annotation ... - String schema = auditTable.schema(); + String schema = schemaFromAnnotation; // ... if empty, try using the default ... if (StringTools.isEmpty(schema)) { schema = globalCfg.getDefaultSchemaName(); @@ -193,9 +193,9 @@ public final class AuditMetadataGenerator { return schema; } - private String getCatalog(AuditTable auditTable, Table table) { + protected String getCatalog(String catalogFromAnnotation, Table table) { // Get the catalog from the annotation ... - String catalog = auditTable.catalog(); + String catalog = catalogFromAnnotation; // ... if empty, try using the default ... if (StringTools.isEmpty(catalog)) { catalog = globalCfg.getDefaultCatalogName(); @@ -232,8 +232,8 @@ public final class AuditMetadataGenerator { auditTableName = verEntCfg.getAuditEntityName(originalTableName); } - String schema = getSchema(auditingData.getAuditTable(), join.getTable()); - String catalog = getCatalog(auditingData.getAuditTable(), join.getTable()); + String schema = getSchema(auditingData.getAuditTable().schema(), join.getTable()); + String catalog = getCatalog(auditingData.getAuditTable().catalog(), join.getTable()); Element joinElement = MetadataTools.createJoin(parent, auditTableName, schema, catalog); joinElements.put(join, joinElement); @@ -311,8 +311,8 @@ public final class AuditMetadataGenerator { @SuppressWarnings({"unchecked"}) public void generateFirstPass(PersistentClass pc, ClassAuditingData auditingData, EntityXmlMappingData xmlMappingData, boolean isAudited) { - String schema = getSchema(auditingData.getAuditTable(), pc.getTable()); - String catalog = getCatalog(auditingData.getAuditTable(), pc.getTable()); + String schema = getSchema(auditingData.getAuditTable().schema(), pc.getTable()); + String catalog = getCatalog(auditingData.getAuditTable().catalog(), pc.getTable()); if (!isAudited) { String entityName = pc.getEntityName(); diff --git a/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java b/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java index d645fa2a20..1eceb2c8ae 100644 --- a/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java +++ b/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java @@ -475,10 +475,8 @@ public final class CollectionMetadataGenerator { } private Element createMiddleEntityXml(String auditMiddleTableName, String auditMiddleEntityName) { - String schema = StringTools.isEmpty(propertyAuditingData.getJoinTable().schema()) ? - propertyValue.getCollectionTable().getSchema() : propertyAuditingData.getJoinTable().schema(); - String catalog = StringTools.isEmpty(propertyAuditingData.getJoinTable().catalog()) ? - propertyValue.getCollectionTable().getCatalog() : propertyAuditingData.getJoinTable().catalog(); + String schema = mainGenerator.getSchema(propertyAuditingData.getJoinTable().schema(), propertyValue.getCollectionTable()); + String catalog = mainGenerator.getCatalog(propertyAuditingData.getJoinTable().catalog(), propertyValue.getCollectionTable()); Element middleEntityXml = MetadataTools.createEntity(xmlMappingData.newAdditionalMapping(), new AuditTableData(auditMiddleEntityName, auditMiddleTableName, schema, catalog), null);