Author: adamw
Date: 2009-04-30 01:47:36 -0400 (Thu, 30 Apr 2009)
New Revision: 16483
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java
Log:
HHH-3888, ENVERS-70:
- copying the scale, precision and sql-type attributes to the column definition
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java 2009-04-29
21:18:35 UTC (rev 16482)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java 2009-04-30
05:47:36 UTC (rev 16483)
@@ -76,11 +76,11 @@
Element idProperty = MetadataTools.addNativelyGeneratedId(class_mapping,
revisionInfoIdData.getName(),
revisionPropType);
- MetadataTools.addColumn(idProperty, "REV", null);
+ MetadataTools.addColumn(idProperty, "REV", null, 0, 0, null);
Element timestampProperty = MetadataTools.addProperty(class_mapping,
revisionInfoTimestampData.getName(),
revisionInfoTimestampType, true, false);
- MetadataTools.addColumn(timestampProperty, "REVTSTMP", null);
+ MetadataTools.addColumn(timestampProperty, "REVTSTMP", null, 0, 0,
null);
return document;
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-04-29
21:18:35 UTC (rev 16482)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-04-30
05:47:36 UTC (rev 16483)
@@ -90,7 +90,7 @@
void addRevisionInfoRelation(Element any_mapping) {
Element rev_mapping = (Element) revisionInfoRelationMapping.clone();
rev_mapping.addAttribute("name", verEntCfg.getRevisionFieldName());
- MetadataTools.addColumn(rev_mapping, verEntCfg.getRevisionFieldName(), null);
+ MetadataTools.addColumn(rev_mapping, verEntCfg.getRevisionFieldName(), null, 0,
0, null);
any_mapping.add(rev_mapping);
}
@@ -197,7 +197,7 @@
Element joinKey = joinElement.addElement("key");
MetadataTools.addColumns(joinKey, join.getKey().getColumnIterator());
- MetadataTools.addColumn(joinKey, verEntCfg.getRevisionFieldName(), null);
+ MetadataTools.addColumn(joinKey, verEntCfg.getRevisionFieldName(), null, 0,
0, null);
}
}
@@ -303,7 +303,7 @@
// Adding the "key" element with all columns + the revision
number column
Element keyMapping = mappingData.getFirst().addElement("key");
MetadataTools.addColumns(keyMapping,
pc.getIdentifierProperty().getColumnIterator());
- MetadataTools.addColumn(keyMapping, verEntCfg.getRevisionFieldName(),
null);
+ MetadataTools.addColumn(keyMapping, verEntCfg.getRevisionFieldName(),
null, 0, 0, null);
break;
case TABLE_PER_CLASS:
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java 2009-04-29
21:18:35 UTC (rev 16482)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java 2009-04-30
05:47:36 UTC (rev 16483)
@@ -68,13 +68,23 @@
return prop_mapping;
}
- public static Element addColumn(Element parent, String name, Integer length) {
+ public static Element addColumn(Element parent, String name, Integer length, Integer
scale, Integer precision,
+ String sqlType) {
Element column_mapping = parent.addElement("column");
column_mapping.addAttribute("name", name);
if (length != null) {
column_mapping.addAttribute("length", length.toString());
}
+ if (scale != 0) {
+ column_mapping.addAttribute("scale", Integer.toString(scale));
+ }
+ if (precision != 0) {
+ column_mapping.addAttribute("precision", Integer.toString(precision));
+ }
+ if (sqlType != null) {
+ column_mapping.addAttribute("sql-type", sqlType);
+ }
return column_mapping;
}
@@ -142,7 +152,8 @@
public static void addColumns(Element any_mapping, Iterator<Column> columns) {
while (columns.hasNext()) {
Column column = columns.next();
- addColumn(any_mapping, column.getName(), column.getLength());
+ addColumn(any_mapping, column.getName(), column.getLength(),
column.getScale(), column.getPrecision(),
+ column.getSqlType());
}
}