Author: adamw
Date: 2009-12-07 03:55:15 -0500 (Mon, 07 Dec 2009)
New Revision: 18152
Modified:
core/trunk/documentation/envers/src/main/docbook/en-US/content/configuration.xml
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java
core/trunk/envers/src/main/java/org/hibernate/envers/tools/Tools.java
Log:
HHH-4645:
- renaming properties from camel case to use _ to separate words, as is the Hibernate
convention
- old property names are still supported
- updating documentation
Modified:
core/trunk/documentation/envers/src/main/docbook/en-US/content/configuration.xml
===================================================================
---
core/trunk/documentation/envers/src/main/docbook/en-US/content/configuration.xml 2009-12-07
08:46:11 UTC (rev 18151)
+++
core/trunk/documentation/envers/src/main/docbook/en-US/content/configuration.xml 2009-12-07
08:55:15 UTC (rev 18152)
@@ -60,7 +60,7 @@
<tbody>
<row>
<entry>
-
<property>org.hibernate.envers.auditTablePrefix</property>
+
<property>org.hibernate.envers.audit_table_prefix</property>
</entry>
<entry>
@@ -72,7 +72,7 @@
</row>
<row>
<entry>
-
<property>org.hibernate.envers.auditTableSuffix</property>
+
<property>org.hibernate.envers.audit_table_suffix</property>
</entry>
<entry>
_AUD
@@ -86,7 +86,7 @@
</row>
<row>
<entry>
-
<property>org.hibernate.envers.revisionFieldName</property>
+
<property>org.hibernate.envers.revision_field_name</property>
</entry>
<entry>
REV
@@ -97,7 +97,7 @@
</row>
<row>
<entry>
-
<property>org.hibernate.envers.revisionTypeFieldName</property>
+
<property>org.hibernate.envers.revision_type_field_name</property>
</entry>
<entry>
REVTYPE
@@ -109,7 +109,7 @@
</row>
<row>
<entry>
-
<property>org.hibernate.envers.revisionOnCollectionChange</property>
+
<property>org.hibernate.envers.revision_on_collection_change</property>
</entry>
<entry>
true
@@ -122,7 +122,7 @@
</row>
<row>
<entry>
-
<property>org.hibernate.envers.doNotAuditOptimisticLockingField</property>
+
<property>org.hibernate.envers.do_not_audit_optimistic_locking_field</property>
</entry>
<entry>
true
@@ -135,7 +135,7 @@
</row>
<row>
<entry>
-
<property>org.hibernate.envers.storeDataAtDelete</property>
+
<property>org.hibernate.envers.store_data_at_delete</property>
</entry>
<entry>
false
@@ -150,7 +150,7 @@
</row>
<row>
<entry>
-
<property>org.hibernate.envers.defaultAuditTableSchemaName</property>
+
<property>org.hibernate.envers.default_audit_table_schema_name</property>
</entry>
<entry>
null (same as normal tables)
@@ -163,7 +163,7 @@
</row>
<row>
<entry>
-
<property>org.hibernate.envers.defaultAuditTableCatalogName</property>
+
<property>org.hibernate.envers.default_audit_table_catalog_name</property>
</entry>
<entry>
null (same as normal tables)
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java 2009-12-07
08:46:11 UTC (rev 18151)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java 2009-12-07
08:55:15 UTC (rev 18152)
@@ -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/trunk/envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java 2009-12-07
08:46:11 UTC (rev 18151)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java 2009-12-07
08:55:15 UTC (rev 18152)
@@ -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/trunk/envers/src/main/java/org/hibernate/envers/tools/Tools.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/tools/Tools.java 2009-12-07
08:46:11 UTC (rev 18151)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/tools/Tools.java 2009-12-07
08:55:15 UTC (rev 18152)
@@ -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;
+ }
+ }
}