@@ -262,22 +262,26 @@ private static void ensureTtlIndex(final CollectionOperations collection, final
262
262
}
263
263
264
264
private static void ensureMDIndex (final CollectionOperations collection , final MDIndex annotation , Collection <IndexEntity > existing ) {
265
- collection .ensureMDIndex (Arrays .asList (annotation .fields ()),
266
- new MDIndexOptions ()
267
- .unique (annotation .unique ())
268
- .fieldValueTypes (annotation .fieldValueTypes ())
269
- .sparse (annotation .sparse ())
270
- );
265
+ final MDIndexOptions options = new MDIndexOptions ()
266
+ .unique (annotation .unique ())
267
+ .fieldValueTypes (annotation .fieldValueTypes ())
268
+ .sparse (annotation .sparse ());
269
+ Collection <String > fields = Arrays .asList (annotation .fields ());
270
+ if (createNewIndex (IndexType .mdi , fields , existing )) {
271
+ existing .add (collection .ensureMDIndex (fields , options ));
272
+ }
271
273
}
272
274
273
275
private static void ensureMDPrefixedIndex (final CollectionOperations collection , final MDPrefixedIndex annotation , Collection <IndexEntity > existing ) {
274
- collection .ensureMDPrefixedIndex (Arrays .asList (annotation .fields ()),
275
- new MDPrefixedIndexOptions ()
276
- .prefixFields (Arrays .asList (annotation .prefixFields ()))
277
- .unique (annotation .unique ())
278
- .fieldValueTypes (annotation .fieldValueTypes ())
279
- .sparse (annotation .sparse ())
280
- );
276
+ final MDPrefixedIndexOptions options = new MDPrefixedIndexOptions ()
277
+ .prefixFields (Arrays .asList (annotation .prefixFields ()))
278
+ .unique (annotation .unique ())
279
+ .fieldValueTypes (annotation .fieldValueTypes ())
280
+ .sparse (annotation .sparse ());
281
+ Collection <String > fields = Arrays .asList (annotation .fields ());
282
+ if (createNewIndex (IndexType .mdiPrefixed , fields , existing )) {
283
+ existing .add (collection .ensureMDPrefixedIndex (fields , options ));
284
+ }
281
285
}
282
286
283
287
private static boolean createNewIndex (IndexType type , Collection <String > fields , Collection <IndexEntity > existing ) {
@@ -574,7 +578,7 @@ public <T> T repsert(final T value, AqlQueryOptions options) throws DataAccessEx
574
578
bindVars ,
575
579
options , clazz
576
580
);
577
- result = it .hasNext () ? it . next () : null ;
581
+ result = it .next ();
578
582
} catch (final ArangoDBException e ) {
579
583
throw translateException (e );
580
584
}
0 commit comments