From 86c15fd21234381e2cc713d07e9652f01078613d Mon Sep 17 00:00:00 2001 From: Lukasz Antoniak Date: Tue, 19 Apr 2011 18:10:25 +0200 Subject: [PATCH] HHH-5276 - Refactoring --- .../envers/configuration/AuditConfiguration.java | 4 ++-- .../configuration/RevisionInfoConfiguration.java | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java index 3c18382d09..969efd46f2 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java @@ -83,10 +83,10 @@ public class AuditConfiguration { Properties properties = cfg.getProperties(); ReflectionManager reflectionManager = cfg.getReflectionManager(); - RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration(); + globalCfg = new GlobalConfiguration(properties); + RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration(globalCfg); RevisionInfoConfigurationResult revInfoCfgResult = revInfoCfg.configure(cfg, reflectionManager); auditEntCfg = new AuditEntitiesConfiguration(properties, revInfoCfgResult.getRevisionInfoEntityName()); - globalCfg = new GlobalConfiguration(properties); auditProcessManager = new AuditProcessManager(revInfoCfgResult.getRevisionInfoGenerator()); revisionInfoQueryCreator = revInfoCfgResult.getRevisionInfoQueryCreator(); revisionInfoNumberReader = revInfoCfgResult.getRevisionInfoNumberReader(); diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java index 843a793a4e..908cb5ba04 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java @@ -59,11 +59,13 @@ public class RevisionInfoConfiguration { private PropertyData revisionInfoIdData; private PropertyData revisionInfoTimestampData; private Type revisionInfoTimestampType; + private GlobalConfiguration globalCfg; private String revisionPropType; private String revisionPropSqlType; - public RevisionInfoConfiguration() { + public RevisionInfoConfiguration(GlobalConfiguration globalCfg) { + this.globalCfg = globalCfg; revisionInfoEntityName = "org.hibernate.envers.DefaultRevisionEntity"; revisionInfoIdData = new PropertyData("id", "id", "field", null); revisionInfoTimestampData = new PropertyData("timestamp", "timestamp", "field", null); @@ -72,10 +74,10 @@ public class RevisionInfoConfiguration { revisionPropType = "integer"; } - private Document generateDefaultRevisionInfoXmlMapping(Configuration cfg) { + private Document generateDefaultRevisionInfoXmlMapping() { Document document = DocumentHelper.createDocument(); - Element class_mapping = MetadataTools.createEntity(document, new AuditTableData(null, null, cfg.getProperty("org.hibernate.envers.default_schema"), cfg.getProperty("org.hibernate.envers.default_catalog")), null); + Element class_mapping = MetadataTools.createEntity(document, new AuditTableData(null, null, globalCfg.getDefaultSchemaName(), globalCfg.getDefaultCatalogName()), null); class_mapping.addAttribute("name", revisionInfoEntityName); class_mapping.addAttribute("table", "REVINFO"); @@ -236,7 +238,7 @@ public class RevisionInfoConfiguration { revisionInfoClass = DefaultRevisionEntity.class; revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass, RevisionListener.class, revisionInfoTimestampData, isTimestampAsDate()); - revisionInfoXmlMapping = generateDefaultRevisionInfoXmlMapping(cfg); + revisionInfoXmlMapping = generateDefaultRevisionInfoXmlMapping(); } return new RevisionInfoConfigurationResult(