diff --git a/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java b/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java index d60afb47ca..19dfbc7ab4 100644 --- a/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java +++ b/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java @@ -76,11 +76,11 @@ public class RevisionInfoConfiguration { 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; } diff --git a/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java b/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java index 255511fd70..497da5901d 100644 --- a/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java +++ b/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java @@ -90,7 +90,7 @@ public final class AuditMetadataGenerator { 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 @@ public final class AuditMetadataGenerator { 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 @@ public final class AuditMetadataGenerator { // 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: diff --git a/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java b/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java index 20b51e034a..eea38feb35 100644 --- a/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java +++ b/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java @@ -68,13 +68,23 @@ public class MetadataTools { 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 class MetadataTools { public static void addColumns(Element any_mapping, Iterator 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()); } }