Author: adamw
Date: 2009-12-07 07:24:42 -0500 (Mon, 07 Dec 2009)
New Revision: 18155
Modified:
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/tools/Tools.java
Log:
svn merge -r 18150:18152
https://svn.jboss.org/repos/hibernate/core/trunk/envers .
Modified:
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
===================================================================
---
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java 2009-12-07
12:20:15 UTC (rev 18154)
+++
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java 2009-12-07
12:24:42 UTC (rev 18155)
@@ -23,6 +23,8 @@
*/
package org.hibernate.envers.configuration;
+import static org.hibernate.envers.tools.Tools.getProperty;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -51,14 +53,26 @@
public AuditEntitiesConfiguration(Properties properties, String
revisionInfoEntityName) {
this.revisionInfoEntityName = revisionInfoEntityName;
- auditTablePrefix =
properties.getProperty("org.hibernate.envers.auditTablePrefix", "");
- auditTableSuffix =
properties.getProperty("org.hibernate.envers.auditTableSuffix",
"_AUD");
+ auditTablePrefix = getProperty(properties,
+ "org.hibernate.envers.audit_table_prefix",
+ "org.hibernate.envers.auditTablePrefix",
+ "");
+ auditTableSuffix = getProperty(properties,
+ "org.hibernate.envers.audit_table_suffix",
+ "org.hibernate.envers.auditTableSuffix",
+ "_AUD");
originalIdPropName = "originalId";
- revisionFieldName =
properties.getProperty("org.hibernate.envers.revisionFieldName",
"REV");
+ revisionFieldName = getProperty(properties,
+ "org.hibernate.envers.revision_field_name",
+ "org.hibernate.envers.revisionFieldName",
+ "REV");
- revisionTypePropName =
properties.getProperty("org.hibernate.envers.revisionTypeFieldName",
"REVTYPE");
+ revisionTypePropName = getProperty(properties,
+ "org.hibernate.envers.revision_type_field_name",
+ "org.hibernate.envers.revisionTypeFieldName",
+ "REVTYPE");
revisionTypePropType = "byte";
customAuditTablesNames = new HashMap<String, String>();
Modified:
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java
===================================================================
---
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java 2009-12-07
12:20:15 UTC (rev 18154)
+++
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java 2009-12-07
12:24:42 UTC (rev 18155)
@@ -23,6 +23,8 @@
*/
package org.hibernate.envers.configuration;
+import static org.hibernate.envers.tools.Tools.getProperty;
+
import java.util.Properties;
/**
@@ -54,19 +56,26 @@
private final String correlatedSubqueryOperator;
public GlobalConfiguration(Properties properties) {
- String generateRevisionsForCollectionsStr =
properties.getProperty("org.hibernate.envers.revisionOnCollectionChange",
+ String generateRevisionsForCollectionsStr = getProperty(properties,
+ "org.hibernate.envers.revision_on_collection_change",
+ "org.hibernate.envers.revisionOnCollectionChange",
"true");
generateRevisionsForCollections =
Boolean.parseBoolean(generateRevisionsForCollectionsStr);
- String ignoreOptimisticLockingPropertyStr =
properties.getProperty("org.hibernate.envers.doNotAuditOptimisticLockingField",
+ String ignoreOptimisticLockingPropertyStr = getProperty(properties,
+ "org.hibernate.envers.do_not_audit_optimistic_locking_field",
+ "org.hibernate.envers.doNotAuditOptimisticLockingField",
"true");
doNotAuditOptimisticLockingField =
Boolean.parseBoolean(ignoreOptimisticLockingPropertyStr);
- String storeDataDeletedEntityStr =
properties.getProperty("org.hibernate.envers.storeDataAtDelete",
"false");
+ String storeDataDeletedEntityStr = getProperty(properties,
+ "org.hibernate.envers.store_data_at_delete",
+ "org.hibernate.envers.storeDataAtDelete",
+ "false");
storeDataAtDelete = Boolean.parseBoolean(storeDataDeletedEntityStr);
- defaultSchemaName =
properties.getProperty("org.hibernate.envers.defaultAuditTableSchemaName",
null);
- defaultCatalogName =
properties.getProperty("org.hibernate.envers.defaultAuditTableCatalogName",
null);
+ defaultSchemaName =
properties.getProperty("org.hibernate.envers.default_audit_table_schema_name",
null);
+ defaultCatalogName =
properties.getProperty("org.hibernate.envers.default_audit_table_catalog_name",
null);
correlatedSubqueryOperator =
"org.hibernate.dialect.HSQLDialect".equals(
properties.getProperty("hibernate.dialect")) ? "in" :
"=";
Modified:
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/tools/Tools.java
===================================================================
---
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/tools/Tools.java 2009-12-07
12:20:15 UTC (rev 18154)
+++
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/tools/Tools.java 2009-12-07
12:24:42 UTC (rev 18155)
@@ -107,6 +107,7 @@
}
}
+ //noinspection RedundantIfStatement
if (iter1.hasNext() || iter2.hasNext()) {
return false;
}
@@ -128,4 +129,22 @@
return ret;
}
+
+ /**
+ * @param properties Properties from which to read.
+ * @param propertyName The name of the property.
+ * @param legacyPropertyName Legacy name of the property. The value of this property
is read if value for
+ * {@code propertyName} is not set.
+ * @param defaultValue Default value returned if a value neither for {@code
propertyName} or
+ * {@code legacyPropertyName} is set.
+ * @return The value of the property, legacy proparty or the default value, if
neither of the values are not set.
+ */
+ public static String getProperty(Properties properties, String propertyName, String
legacyPropertyName, String defaultValue) {
+ String value = properties.getProperty(propertyName, null);
+ if (value == null) {
+ return properties.getProperty(legacyPropertyName, defaultValue);
+ } else {
+ return value;
+ }
+ }
}