45
45
import com .arangodb .springframework .core .mapping .event .ArangoMappingEvent ;
46
46
import com .arangodb .springframework .core .mapping .event .BeforeDeleteEvent ;
47
47
import com .arangodb .springframework .core .mapping .event .BeforeSaveEvent ;
48
- import com .arangodb .springframework .core .template .DefaultUserOperation .CollectionCallback ;
49
48
import com .arangodb .springframework .core .util .ArangoExceptionTranslator ;
50
49
import com .arangodb .springframework .core .util .MetadataUtils ;
51
50
import com .arangodb .util .MapBuilder ;
52
51
import com .arangodb .velocypack .VPackSlice ;
52
+ import org .slf4j .Logger ;
53
+ import org .slf4j .LoggerFactory ;
53
54
import org .springframework .beans .BeansException ;
54
55
import org .springframework .context .ApplicationContext ;
55
56
import org .springframework .context .ApplicationContextAware ;
73
74
import java .util .Collections ;
74
75
import java .util .HashMap ;
75
76
import java .util .Iterator ;
77
+ import java .util .List ;
76
78
import java .util .Map ;
77
79
import java .util .Map .Entry ;
78
80
import java .util .Optional ;
@@ -98,6 +100,7 @@ public class ArangoTemplate implements ArangoOperations, CollectionCallback, App
98
100
private static final String REPSERT_QUERY = "LET doc = @doc " + REPSERT_QUERY_BODY ;
99
101
private static final String REPSERT_MANY_QUERY = "FOR doc IN @docs " + REPSERT_QUERY_BODY ;
100
102
103
+ private static final Logger LOGGER = LoggerFactory .getLogger (ArangoTemplate .class );
101
104
private static final SpelExpressionParser PARSER = new SpelExpressionParser ();
102
105
103
106
private volatile ArangoDBVersion version ;
@@ -191,7 +194,9 @@ private ArangoCollection _collection(final String name, final ArangoPersistentEn
191
194
final ArangoCollection collection = value .getCollection ();
192
195
if (persistentEntity != null && !entities .contains (entityClass )) {
193
196
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 {
195
200
ensureCollectionIndexes (collection (collection ), persistentEntity );
196
201
}
197
202
}
@@ -761,8 +766,13 @@ public CollectionOperations collection(final Class<?> entityClass) throws DataAc
761
766
}
762
767
763
768
@ 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 );
766
776
}
767
777
768
778
@ Override
0 commit comments