From 0fd6f66181ea8364b42f2caae86a6855c34ff6dc Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Wed, 15 Dec 2010 03:25:40 +0000 Subject: [PATCH] This was very confused. Unique columns are automatically indexed. Thus we should certainly not create an explicit index when we encounter a unique column, as we were doing, and we will even go so far as to forbid an explicit index. --- .../com/samskivert/depot/impl/DepotMarshaller.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/samskivert/depot/impl/DepotMarshaller.java b/src/main/java/com/samskivert/depot/impl/DepotMarshaller.java index b700b90..b3f2a30 100644 --- a/src/main/java/com/samskivert/depot/impl/DepotMarshaller.java +++ b/src/main/java/com/samskivert/depot/impl/DepotMarshaller.java @@ -201,6 +201,10 @@ public class DepotMarshaller implements QueryMarshal // check whether this field is indexed Index index = field.getAnnotation(Index.class); if (index != null) { + Column column = field.getAnnotation(Column.class); + checkArgument(column == null || !column.unique(), + "Unique columns are implicitly indexed and should not be @Index'd."); + String name = index.name().equals("") ? field.getName() + "Index" : index.name(); Tuple, Order> entry = new Tuple, Order>(fieldColumn, Order.ASC); @@ -214,12 +218,6 @@ public class DepotMarshaller implements QueryMarshal namedFieldIndices.put(name, entry); } } - - // if this column is marked as unique, that also means we create an index - Column column = field.getAnnotation(Column.class); - if (column != null && column.unique()) { - _indexes.add(buildIndex(field.getName() + "Index", true, fieldColumn)); - } } for (String indexName : namedFieldIndices.keySet()) {