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
@@ -349,7 +346,7 @@ public MultiDocumentEntity<? extends DocumentEntity> delete(final Iterable<Objec
349
346
try {
350
347
result = _collection (entityClass ).deleteDocuments (toJsonNodeCollection (values ), options , entityClass );
351
348
} catch (final ArangoDBException e ) {
352
- throw translateExceptionIfPossible ( e );
349
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
353
350
}
354
351
355
352
potentiallyEmitAfterDeleteEvent (values , entityClass , result );
@@ -372,7 +369,7 @@ public DocumentEntity delete(final Object id, final Class<?> entityClass, final
372
369
try {
373
370
result = _collection (entityClass , id ).deleteDocument (determineDocumentKeyFromId (id ), options , entityClass );
374
371
} catch (final ArangoDBException e ) {
375
- throw translateExceptionIfPossible ( e );
372
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
376
373
}
377
374
378
375
potentiallyEmitEvent (new AfterDeleteEvent <>(id , entityClass ));
@@ -394,7 +391,7 @@ public <T> MultiDocumentEntity<? extends DocumentEntity> update(final Iterable<T
394
391
try {
395
392
result = _collection (entityClass ).updateDocuments (toJsonNodeCollection (values ), options );
396
393
} catch (final ArangoDBException e ) {
397
- throw translateExceptionIfPossible ( e );
394
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
398
395
}
399
396
400
397
updateDBFields (values , result );
@@ -419,7 +416,7 @@ public DocumentEntity update(final Object id, final Object value, final Document
419
416
result = _collection (value .getClass (), id ).updateDocument (determineDocumentKeyFromId (id ), toJsonNode (value ),
420
417
options );
421
418
} catch (final ArangoDBException e ) {
422
- throw translateExceptionIfPossible ( e );
419
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
423
420
}
424
421
425
422
updateDBFields (value , result );
@@ -442,7 +439,7 @@ public <T> MultiDocumentEntity<? extends DocumentEntity> replace(final Iterable<
442
439
try {
443
440
result = _collection (entityClass ).replaceDocuments (toJsonNodeCollection (values ), options );
444
441
} catch (final ArangoDBException e ) {
445
- throw translateExceptionIfPossible ( e );
442
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
446
443
}
447
444
448
445
updateDBFields (values , result );
@@ -466,7 +463,7 @@ public DocumentEntity replace(final Object id, final Object value, final Documen
466
463
result = _collection (value .getClass (), id ).replaceDocument (determineDocumentKeyFromId (id ), toJsonNode (value ),
467
464
options );
468
465
} catch (final ArangoDBException e ) {
469
- throw translateExceptionIfPossible ( e );
466
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
470
467
}
471
468
472
469
updateDBFields (value , result );
@@ -487,7 +484,7 @@ public <T> Optional<T> find(final Object id, final Class<T> entityClass, final D
487
484
JsonNode .class , options );
488
485
return Optional .ofNullable (fromJsonNode (entityClass , doc ));
489
486
} catch (final ArangoDBException e ) {
490
- throw translateExceptionIfPossible ( e );
487
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
491
488
}
492
489
}
493
490
@@ -512,7 +509,7 @@ public <T> Iterable<T> find(final Iterable<?> ids, final Class<T> entityClass)
512
509
final MultiDocumentEntity <JsonNode > docs = _collection (entityClass ).getDocuments (keys , JsonNode .class );
513
510
return docs .getDocuments ().stream ().map (doc -> fromJsonNode (entityClass , doc )).collect (Collectors .toList ());
514
511
} catch (final ArangoDBException e ) {
515
- throw translateExceptionIfPossible ( e );
512
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
516
513
}
517
514
}
518
515
@@ -526,7 +523,7 @@ public <T> MultiDocumentEntity<? extends DocumentEntity> insert(final Iterable<T
526
523
try {
527
524
result = _collection (entityClass ).insertDocuments (toJsonNodeCollection (values ), options );
528
525
} catch (final ArangoDBException e ) {
529
- throw translateExceptionIfPossible ( e );
526
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
530
527
}
531
528
532
529
updateDBFields (values , result );
@@ -631,7 +628,7 @@ public <T> void repsert(final Iterable<? extends T> values, final Class<T> entit
631
628
entityClass
632
629
).asListRemaining ();
633
630
} catch (final ArangoDBException e ) {
634
- throw translateExceptionIfPossible ( e );
631
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
635
632
}
636
633
637
634
updateDBFieldsFromObjects (values , result );
@@ -711,7 +708,7 @@ public boolean exists(final Object id, final Class<?> entityClass) throws DataAc
711
708
try {
712
709
return _collection (entityClass ).documentExists (determineDocumentKeyFromId (id ));
713
710
} catch (final ArangoDBException e ) {
714
- throw translateExceptionIfPossible ( e );
711
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
715
712
}
716
713
}
717
714
@@ -721,7 +718,7 @@ public void dropDatabase() throws DataAccessException {
721
718
try {
722
719
db .drop ();
723
720
} catch (final ArangoDBException e ) {
724
- throw translateExceptionIfPossible ( e );
721
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
725
722
}
726
723
databaseCache .remove (db .name ());
727
724
collectionCache .keySet ().stream ().filter (key -> key .getDb ().equals (db .name ()))
@@ -758,7 +755,7 @@ public Iterable<UserEntity> getUsers() throws DataAccessException {
758
755
try {
759
756
return arango .getUsers ();
760
757
} catch (final ArangoDBException e ) {
761
- throw translateExceptionIfPossible ( e );
758
+ throw DataAccessUtils . translateIfNecessary ( e , exceptionTranslator );
762
759
}
763
760
}
764
761
0 commit comments