diff --git a/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java b/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java index 9b0a73a..bc4a799 100644 --- a/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java +++ b/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java @@ -178,11 +178,13 @@ public abstract class FieldMarshaller int length = 255; boolean nullable = false; boolean unique = false; + String defval = ""; Column column = _field.getAnnotation(Column.class); if (column != null) { nullable = column.nullable(); unique = column.unique(); length = column.length(); + defval = column.defaultValue(); if (!StringUtil.isBlank(column.name())) { _columnName = column.name(); } @@ -219,6 +221,11 @@ public abstract class FieldMarshaller if (unique) { builder.append(" UNIQUE"); } + + // append the default value if one was specified + if (defval.length() > 0) { + builder.append(" DEFAULT ").append(defval); + } } // handle primary keyness diff --git a/src/java/com/samskivert/jdbc/depot/annotation/Column.java b/src/java/com/samskivert/jdbc/depot/annotation/Column.java index b33ba72..bc3998d 100644 --- a/src/java/com/samskivert/jdbc/depot/annotation/Column.java +++ b/src/java/com/samskivert/jdbc/depot/annotation/Column.java @@ -62,4 +62,11 @@ public @interface Column * The column length. (Applies to String and byte[] columns.) */ int length () default 255; + + /** + * The SQL literal value to be used when defining this column's default value. The value must + * be quoted and escaped if it is not a SQL primitive datatype. For example: + * '2006-01-01' or 25 or NULL. + */ + String defaultValue () default ""; }