From 0569f8f8ff476d653e893ca1f7e8c16133e501b7 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Thu, 22 Jan 2009 16:43:21 +0000 Subject: [PATCH] The buildIndex() magic expects an array of colums, not a list. --- .../samskivert/depot/impl/DepotMarshaller.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/java/com/samskivert/depot/impl/DepotMarshaller.java b/src/java/com/samskivert/depot/impl/DepotMarshaller.java index 94f9e5a..4723c2f 100644 --- a/src/java/com/samskivert/depot/impl/DepotMarshaller.java +++ b/src/java/com/samskivert/depot/impl/DepotMarshaller.java @@ -40,6 +40,7 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.samskivert.util.ArrayUtil; +import com.samskivert.util.StringUtil; import com.samskivert.util.Tuple; import com.samskivert.jdbc.ColumnDefinition; @@ -229,14 +230,15 @@ public class DepotMarshaller if (entity != null) { // add any indices needed for uniqueness constraints for (UniqueConstraint constraint : entity.uniqueConstraints()) { - List colExps = Lists.newArrayList(); + ColumnExp[] colExps = new ColumnExp[constraint.fields().length]; + int ii = 0; for (String field : constraint.fields()) { FieldMarshaller fm = _fields.get(field); if (fm == null) { throw new IllegalArgumentException( "Unknown unique constraint field: " + field); } - colExps.add(new ColumnExp(_pClass, field)); + colExps[ii ++] = new ColumnExp(_pClass, field); } _indexes.add(buildIndex(constraint.name(), true, colExps)); } @@ -496,7 +498,7 @@ public class DepotMarshaller if (getTableName() == null) { return; } - + // figure out the list of fields that correspond to actual table columns and generate the // SQL used to create and migrate our table (unless we're a computed entity) _columnFields = new String[_allFields.length]; @@ -535,7 +537,7 @@ public class DepotMarshaller return 0; } }); - + // fetch all relevant information regarding our table from the database TableMetaData metaData = TableMetaData.load(ctx, getTableName()); @@ -1118,6 +1120,11 @@ public class DepotMarshaller pkColumns.add(rs.getString("COLUMN_NAME")); } } + + public String toString () + { + return StringUtil.fieldsToString(this); + } } /** The persistent object class that we manage. */