4545import com .arangodb .springframework .core .mapping .event .ArangoMappingEvent ;
4646import com .arangodb .springframework .core .mapping .event .BeforeDeleteEvent ;
4747import com .arangodb .springframework .core .mapping .event .BeforeSaveEvent ;
48- import com .arangodb .springframework .core .template .DefaultUserOperation .CollectionCallback ;
4948import com .arangodb .springframework .core .util .ArangoExceptionTranslator ;
5049import com .arangodb .springframework .core .util .MetadataUtils ;
5150import com .arangodb .util .MapBuilder ;
5251import com .arangodb .velocypack .VPackSlice ;
52+ import org .slf4j .Logger ;
53+ import org .slf4j .LoggerFactory ;
5354import org .springframework .beans .BeansException ;
5455import org .springframework .context .ApplicationContext ;
5556import org .springframework .context .ApplicationContextAware ;
7374import java .util .Collections ;
7475import java .util .HashMap ;
7576import java .util .Iterator ;
77+ import java .util .List ;
7678import java .util .Map ;
7779import java .util .Map .Entry ;
7880import java .util .Optional ;
@@ -98,6 +100,7 @@ public class ArangoTemplate implements ArangoOperations, CollectionCallback, App
98100 private static final String REPSERT_QUERY = "LET doc = @doc " + REPSERT_QUERY_BODY ;
99101 private static final String REPSERT_MANY_QUERY = "FOR doc IN @docs " + REPSERT_QUERY_BODY ;
100102
103+ private static final Logger LOGGER = LoggerFactory .getLogger (ArangoTemplate .class );
101104 private static final SpelExpressionParser PARSER = new SpelExpressionParser ();
102105
103106 private volatile ArangoDBVersion version ;
@@ -191,7 +194,9 @@ private ArangoCollection _collection(final String name, final ArangoPersistentEn
191194 final ArangoCollection collection = value .getCollection ();
192195 if (persistentEntity != null && !entities .contains (entityClass )) {
193196 value .addEntityClass (entityClass );
194- if (!transactional ) {
197+ if (transactional ) {
198+ LOGGER .debug ("Not ensuring any indexes of collection {} for {} during transaction" , collection .name (), entityClass );
199+ } else {
195200 ensureCollectionIndexes (collection (collection ), persistentEntity );
196201 }
197202 }
@@ -761,8 +766,13 @@ public CollectionOperations collection(final Class<?> entityClass) throws DataAc
761766 }
762767
763768 @ Override
764- public CollectionOperations collection (String name ) {
765- return ArangoOperations .super .collection (name );
769+ public CollectionOperations collection (String name ) throws DataAccessException {
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 );
766776 }
767777
768778 @ Override
0 commit comments