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:
@@ -201,6 +201,10 @@ public class DepotMarshaller<T extends PersistentRecord> implements QueryMarshal
|
|||||||
// check whether this field is indexed
|
// check whether this field is indexed
|
||||||
Index index = field.getAnnotation(Index.class);
|
Index index = field.getAnnotation(Index.class);
|
||||||
if (index != null) {
|
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();
|
String name = index.name().equals("") ? field.getName() + "Index" : index.name();
|
||||||
Tuple<SQLExpression<?>, Order> entry =
|
Tuple<SQLExpression<?>, Order> entry =
|
||||||
new Tuple<SQLExpression<?>, Order>(fieldColumn, Order.ASC);
|
new Tuple<SQLExpression<?>, Order>(fieldColumn, Order.ASC);
|
||||||
@@ -214,12 +218,6 @@ public class DepotMarshaller<T extends PersistentRecord> implements QueryMarshal
|
|||||||
namedFieldIndices.put(name, entry);
|
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()) {
|
for (String indexName : namedFieldIndices.keySet()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user