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()) {