49
49
import com .arangodb .springframework .core .util .MetadataUtils ;
50
50
import com .arangodb .util .MapBuilder ;
51
51
import com .arangodb .velocypack .VPackSlice ;
52
+ import org .slf4j .Logger ;
53
+ import org .slf4j .LoggerFactory ;
52
54
import org .springframework .beans .BeansException ;
53
55
import org .springframework .context .ApplicationContext ;
54
56
import org .springframework .context .ApplicationContextAware ;
72
74
import java .util .Collections ;
73
75
import java .util .HashMap ;
74
76
import java .util .Iterator ;
77
+ import java .util .List ;
75
78
import java .util .Map ;
76
79
import java .util .Map .Entry ;
77
80
import java .util .Optional ;
@@ -97,6 +100,7 @@ public class ArangoTemplate implements ArangoOperations, CollectionCallback, App
97
100
private static final String REPSERT_QUERY = "LET doc = @doc " + REPSERT_QUERY_BODY ;
98
101
private static final String REPSERT_MANY_QUERY = "FOR doc IN @docs " + REPSERT_QUERY_BODY ;
99
102
103
+ private static final Logger LOGGER = LoggerFactory .getLogger (ArangoTemplate .class );
100
104
private static final SpelExpressionParser PARSER = new SpelExpressionParser ();
101
105
102
106
private volatile ArangoDBVersion version ;
@@ -190,7 +194,9 @@ private ArangoCollection _collection(final String name, final ArangoPersistentEn
190
194
final ArangoCollection collection = value .getCollection ();
191
195
if (persistentEntity != null && !entities .contains (entityClass )) {
192
196
value .addEntityClass (entityClass );
193
- if (!transactional ) {
197
+ if (transactional ) {
198
+ LOGGER .debug ("Not ensuring any indexes of collection {} for {} during transaction" , collection .name (), entityClass );
199
+ } else {
194
200
ensureCollectionIndexes (collection (collection ), persistentEntity );
195
201
}
196
202
}
@@ -761,11 +767,12 @@ public CollectionOperations collection(final Class<?> entityClass) throws DataAc
761
767
762
768
@ Override
763
769
public CollectionOperations collection (String name ) throws DataAccessException {
764
- ArangoPersistentEntity <?> persistentEntity = converter .getMappingContext ().getPersistentEntities ().stream ()
765
- .filter (e -> name .equals (e .getCollection ()))
766
- .findAny ()
767
- .orElse (null );
768
- return collection (_collection (name , persistentEntity , persistentEntity == null ? new CollectionCreateOptions () : persistentEntity .getCollectionOptions (), false ));
770
+ List <ArangoCollection > collections = converter .getMappingContext ().getPersistentEntities ().stream ()
771
+ .filter (persistentEntity -> name .equals (persistentEntity .getCollection ()))
772
+ .map (persistentEntity -> _collection (name , persistentEntity , persistentEntity .getCollectionOptions (), false ))
773
+ .collect (Collectors .toList ());
774
+ ArangoCollection result = collections .isEmpty () ? _collection (name , null , null , false ) : collections .get (0 );
775
+ return collection (result );
769
776
}
770
777
771
778
@ Override
0 commit comments