HHH-3888, ENVERS-70:

- copying the scale, precision and sql-type attributes to the column definition

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16483 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Adam Warski 2009-04-30 05:47:36 +00:00
parent 21aaac2ea4
commit 1553578808
3 changed files with 18 additions and 7 deletions

View File

@ -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;
}

View File

@ -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:

View File

@ -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<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());
}
}