64
64
import org .springframework .context .expression .BeanFactoryAccessor ;
65
65
import org .springframework .context .expression .BeanFactoryResolver ;
66
66
import org .springframework .dao .DataAccessException ;
67
+ import org .springframework .dao .support .DataAccessUtils ;
67
68
import org .springframework .dao .support .PersistenceExceptionTranslator ;
68
69
import org .springframework .data .mapping .PersistentPropertyAccessor ;
69
70
import org .springframework .expression .Expression ;
@@ -150,10 +151,6 @@ private ArangoDatabase db() {
150
151
});
151
152
}
152
153
153
- private DataAccessException translateExceptionIfPossible (final RuntimeException exception ) {
154
- return exceptionTranslator .translateExceptionIfPossible (exception );
155
- }
156
-
157
154
private ArangoCollection _collection (final String name ) {
158
155
return _collection (name , null , null );
159
156
}
@@ -299,7 +296,7 @@ public ArangoDBVersion getVersion() throws DataAccessException {
299
296
}
300
297
return version ;
301
298
} catch (final ArangoDBException e ) {
302
- throw translateExceptionIfPossible ( e );
299
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
303
300
}
304
301
}
305
302
@@ -327,7 +324,7 @@ public <T> ArangoCursor<T> query(final String query, final Map<String, Object> b
327
324
ArangoCursor <JsonNode > cursor = db ().query (query , JsonNode .class , bindVars == null ? null : prepareBindVars (bindVars ), options );
328
325
return new ArangoExtCursor <>(cursor , entityClass , converter , eventPublisher );
329
326
} catch (final ArangoDBException e ) {
330
- throw translateExceptionIfPossible ( e );
327
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
331
328
}
332
329
}
333
330
@@ -353,7 +350,7 @@ public MultiDocumentEntity<? extends DocumentEntity> delete(final Iterable<Objec
353
350
try {
354
351
result = _collection (entityClass ).deleteDocuments (toJsonNodeCollection (values ), options , entityClass );
355
352
} catch (final ArangoDBException e ) {
356
- throw translateExceptionIfPossible ( e );
353
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
357
354
}
358
355
359
356
potentiallyEmitAfterDeleteEvent (values , entityClass , result );
@@ -376,7 +373,7 @@ public DocumentEntity delete(final Object id, final Class<?> entityClass, final
376
373
try {
377
374
result = _collection (entityClass , id ).deleteDocument (determineDocumentKeyFromId (id ), options , entityClass );
378
375
} catch (final ArangoDBException e ) {
379
- throw translateExceptionIfPossible ( e );
376
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
380
377
}
381
378
382
379
potentiallyEmitEvent (new AfterDeleteEvent <>(id , entityClass ));
@@ -398,7 +395,7 @@ public <T> MultiDocumentEntity<? extends DocumentEntity> update(final Iterable<T
398
395
try {
399
396
result = _collection (entityClass ).updateDocuments (toJsonNodeCollection (values ), options );
400
397
} catch (final ArangoDBException e ) {
401
- throw translateExceptionIfPossible ( e );
398
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
402
399
}
403
400
404
401
updateDBFields (values , result );
@@ -423,7 +420,7 @@ public DocumentEntity update(final Object id, final Object value, final Document
423
420
result = _collection (value .getClass (), id ).updateDocument (determineDocumentKeyFromId (id ), toJsonNode (value ),
424
421
options );
425
422
} catch (final ArangoDBException e ) {
426
- throw translateExceptionIfPossible ( e );
423
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
427
424
}
428
425
429
426
updateDBFields (value , result );
@@ -446,7 +443,7 @@ public <T> MultiDocumentEntity<? extends DocumentEntity> replace(final Iterable<
446
443
try {
447
444
result = _collection (entityClass ).replaceDocuments (toJsonNodeCollection (values ), options );
448
445
} catch (final ArangoDBException e ) {
449
- throw translateExceptionIfPossible ( e );
446
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
450
447
}
451
448
452
449
updateDBFields (values , result );
@@ -470,7 +467,7 @@ public DocumentEntity replace(final Object id, final Object value, final Documen
470
467
result = _collection (value .getClass (), id ).replaceDocument (determineDocumentKeyFromId (id ), toJsonNode (value ),
471
468
options );
472
469
} catch (final ArangoDBException e ) {
473
- throw translateExceptionIfPossible ( e );
470
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
474
471
}
475
472
476
473
updateDBFields (value , result );
@@ -491,7 +488,7 @@ public <T> Optional<T> find(final Object id, final Class<T> entityClass, final D
491
488
JsonNode .class , options );
492
489
return Optional .ofNullable (fromJsonNode (entityClass , doc ));
493
490
} catch (final ArangoDBException e ) {
494
- throw translateExceptionIfPossible ( e );
491
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
495
492
}
496
493
}
497
494
@@ -516,7 +513,7 @@ public <T> Iterable<T> find(final Iterable<?> ids, final Class<T> entityClass)
516
513
final MultiDocumentEntity <JsonNode > docs = _collection (entityClass ).getDocuments (keys , JsonNode .class );
517
514
return docs .getDocuments ().stream ().map (doc -> fromJsonNode (entityClass , doc )).collect (Collectors .toList ());
518
515
} catch (final ArangoDBException e ) {
519
- throw translateExceptionIfPossible ( e );
516
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
520
517
}
521
518
}
522
519
@@ -530,7 +527,7 @@ public <T> MultiDocumentEntity<? extends DocumentEntity> insert(final Iterable<T
530
527
try {
531
528
result = _collection (entityClass ).insertDocuments (toJsonNodeCollection (values ), options );
532
529
} catch (final ArangoDBException e ) {
533
- throw translateExceptionIfPossible ( e );
530
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
534
531
}
535
532
536
533
updateDBFields (values , result );
@@ -552,7 +549,7 @@ public DocumentEntity insert(final Object value, final DocumentCreateOptions opt
552
549
try {
553
550
result = _collection (value .getClass ()).insertDocument (toJsonNode (value ), options );
554
551
} catch (final ArangoDBException e ) {
555
- throw exceptionTranslator . translateExceptionIfPossible ( e );
552
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
556
553
}
557
554
558
555
updateDBFields (value , result );
@@ -574,7 +571,7 @@ public DocumentEntity insert(final String collectionName, final Object value, fi
574
571
try {
575
572
result = _collection (collectionName ).insertDocument (toJsonNode (value ), options );
576
573
} catch (final ArangoDBException e ) {
577
- throw exceptionTranslator . translateExceptionIfPossible ( e );
574
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
578
575
}
579
576
580
577
updateDBFields (value , result );
@@ -607,7 +604,7 @@ public <T> void repsert(final T value) throws DataAccessException {
607
604
);
608
605
result = it .hasNext () ? it .next () : null ;
609
606
} catch (final ArangoDBException e ) {
610
- throw exceptionTranslator . translateExceptionIfPossible ( e );
607
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
611
608
}
612
609
613
610
updateDBFieldsFromObject (value , result );
@@ -635,7 +632,7 @@ public <T> void repsert(final Iterable<? extends T> values, final Class<T> entit
635
632
entityClass
636
633
).asListRemaining ();
637
634
} catch (final ArangoDBException e ) {
638
- throw translateExceptionIfPossible ( e );
635
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
639
636
}
640
637
641
638
updateDBFieldsFromObjects (values , result );
@@ -715,7 +712,7 @@ public boolean exists(final Object id, final Class<?> entityClass) throws DataAc
715
712
try {
716
713
return _collection (entityClass ).documentExists (determineDocumentKeyFromId (id ));
717
714
} catch (final ArangoDBException e ) {
718
- throw translateExceptionIfPossible ( e );
715
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
719
716
}
720
717
}
721
718
@@ -725,7 +722,7 @@ public void dropDatabase() throws DataAccessException {
725
722
try {
726
723
db .drop ();
727
724
} catch (final ArangoDBException e ) {
728
- throw translateExceptionIfPossible ( e );
725
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
729
726
}
730
727
databaseCache .remove (db .name ());
731
728
collectionCache .keySet ().stream ().filter (key -> key .getDb ().equals (db .name ()))
@@ -762,7 +759,7 @@ public Iterable<UserEntity> getUsers() throws DataAccessException {
762
759
try {
763
760
return arango .getUsers ();
764
761
} catch (final ArangoDBException e ) {
765
- throw translateExceptionIfPossible ( e );
762
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
766
763
}
767
764
}
768
765
0 commit comments