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.

This commit is contained in:
Par Winzell
2010-12-15 03:25:40 +00:00
parent f81b338cd9
commit 0fd6f66181
@@ -201,6 +201,10 @@ public class DepotMarshaller<T extends PersistentRecord> 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<SQLExpression<?>, Order> entry =
new Tuple<SQLExpression<?>, Order>(fieldColumn, Order.ASC);
@@ -214,12 +218,6 @@ public class DepotMarshaller<T extends PersistentRecord> 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()) {