[hibernate-commits] Hibernate SVN: r18057 - core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Nov 25 02:48:51 EST 2009


Author: adamw
Date: 2009-11-25 02:48:51 -0500 (Wed, 25 Nov 2009)
New Revision: 18057

Modified:
   core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
Log:
svn merge -r 18035:18056 https://svn.jboss.org/repos/hibernate/core/trunk/envers .

Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
--- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java	2009-11-25 07:45:45 UTC (rev 18056)
+++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java	2009-11-25 07:48:51 UTC (rev 18057)
@@ -40,14 +40,11 @@
 import org.hibernate.envers.entities.mapper.SubclassPropertyMapper;
 import org.hibernate.envers.tools.StringTools;
 import org.hibernate.envers.tools.Triple;
+import org.hibernate.envers.AuditTable;
 
 import org.hibernate.MappingException;
 import org.hibernate.cfg.Configuration;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.Join;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.Value;
+import org.hibernate.mapping.*;
 import org.hibernate.type.*;
 
 /**
@@ -180,6 +177,38 @@
 		return true;
 	}
 
+    private String getSchema(AuditTable auditTable, Table table) {
+        // Get the schema from the annotation ...
+        String schema = auditTable.schema();
+        // ... if empty, try using the default ...
+        if (StringTools.isEmpty(schema)) {
+            schema = globalCfg.getDefaultSchemaName();
+
+            // ... if still empty, use the same as the normal table.
+            if (StringTools.isEmpty(schema)) {
+                schema = table.getSchema();
+            }
+        }
+
+        return schema;
+    }
+
+    private String getCatalog(AuditTable auditTable, Table table) {
+        // Get the catalog from the annotation ...
+        String catalog = auditTable.catalog();
+        // ... if empty, try using the default ...
+        if (StringTools.isEmpty(catalog)) {
+            catalog = globalCfg.getDefaultCatalogName();
+
+            // ... if still empty, use the same as the normal table.
+            if (StringTools.isEmpty(catalog)) {
+                catalog = table.getCatalog();
+            }
+        }
+
+        return catalog;
+    }
+
     @SuppressWarnings({"unchecked"})
     private void createJoins(PersistentClass pc, Element parent, ClassAuditingData auditingData) {
         Iterator<Join> joins = pc.getJoinIterator();
@@ -203,28 +232,9 @@
                 auditTableName = verEntCfg.getAuditEntityName(originalTableName);
             }
 
-            // Get the schema ...
-            String schema = auditingData.getAuditTable().schema();
-            // ... if empty, try using the default ...
-            if (StringTools.isEmpty(schema)) {
-                schema = globalCfg.getDefaultSchemaName();
+            String schema = getSchema(auditingData.getAuditTable(), join.getTable());
+            String catalog = getCatalog(auditingData.getAuditTable(), join.getTable());
 
-                // ... if still empty, use the same as the normal table.
-                if (StringTools.isEmpty(schema)) {
-                    schema = join.getTable().getSchema();
-                }
-            }
-
-            // Same for catalogs
-            String catalog = auditingData.getAuditTable().catalog();
-            if (StringTools.isEmpty(catalog)) {
-                catalog = globalCfg.getDefaultCatalogName();
-
-                if (StringTools.isEmpty(catalog)) {
-                    catalog = join.getTable().getCatalog();
-                }
-            }
-
             Element joinElement = MetadataTools.createJoin(parent, auditTableName, schema, catalog);
             joinElements.put(join, joinElement);
 
@@ -333,16 +343,9 @@
     @SuppressWarnings({"unchecked"})
     public void generateFirstPass(PersistentClass pc, ClassAuditingData auditingData,
                                   EntityXmlMappingData xmlMappingData, boolean isAudited) {
-        String schema = auditingData.getAuditTable().schema();
-        if (StringTools.isEmpty(schema)) {
-            schema = pc.getTable().getSchema();
-        }
+        String schema = getSchema(auditingData.getAuditTable(), pc.getTable());
+        String catalog = getCatalog(auditingData.getAuditTable(), pc.getTable());
 
-        String catalog = auditingData.getAuditTable().catalog();
-        if (StringTools.isEmpty(catalog)) {
-            catalog = pc.getTable().getCatalog();
-        }
-
 		if (!isAudited) {
 			String entityName = pc.getEntityName();
 			IdMappingData idMapper = idMetadataGenerator.addId(pc);



More information about the hibernate-commits mailing list