Skip to content

Commit 592a0bb

Browse files
committed
fix tx of relation resolvers
1 parent c4910d2 commit 592a0bb

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/main/java/com/arangodb/springframework/core/convert/resolver/DefaultResolverFactory.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.springframework.context.ApplicationContext;
3030
import org.springframework.context.ApplicationContextAware;
3131

32-
import com.arangodb.springframework.annotation.Document;
3332
import com.arangodb.springframework.annotation.Edge;
3433
import com.arangodb.springframework.annotation.From;
3534
import com.arangodb.springframework.annotation.Ref;
@@ -60,27 +59,26 @@ public <A extends Annotation> Optional<ReferenceResolver<A>> getReferenceResolve
6059
@Override
6160
public <A extends Annotation> Optional<RelationResolver<A>> getRelationResolver(final A annotation,
6261
final Class<? extends Annotation> collectionType) {
63-
RelationResolver<A> resolver = null;
6462
try {
6563
if (annotation instanceof From) {
6664
if (collectionType == Edge.class) {
67-
resolver = (RelationResolver<A>) new EdgeFromResolver(template.getObject(), null);
68-
} else if (collectionType == Document.class) {
69-
resolver = (RelationResolver<A>) new DocumentFromResolver(template.getObject(), null);
65+
return Optional.of((RelationResolver<A>) new EdgeFromResolver(template.getObject(), transactionBridge.getIfUnique()));
7066
}
71-
} else if (annotation instanceof To) {
67+
return Optional.of((RelationResolver<A>) new DocumentFromResolver(template.getObject(), transactionBridge.getIfUnique()));
68+
}
69+
if (annotation instanceof To) {
7270
if (collectionType == Edge.class) {
73-
resolver = (RelationResolver<A>) new EdgeToResolver(template.getObject(), null);
74-
} else if (collectionType == Document.class) {
75-
resolver = (RelationResolver<A>) new DocumentToResolver(template.getObject(), null);
71+
return Optional.of((RelationResolver<A>) new EdgeToResolver(template.getObject(), transactionBridge.getIfUnique()));
7672
}
77-
} else if (annotation instanceof Relations) {
78-
resolver = (RelationResolver<A>) new RelationsResolver(template.getObject(), null);
73+
return Optional.of((RelationResolver<A>) new DocumentToResolver(template.getObject(), transactionBridge.getIfUnique()));
74+
}
75+
if (annotation instanceof Relations) {
76+
return Optional.of((RelationResolver<A>) new RelationsResolver(template.getObject(), transactionBridge.getIfUnique()));
7977
}
8078
} catch (final Exception e) {
8179
throw new ArangoDBException(e);
8280
}
83-
return Optional.ofNullable(resolver);
81+
return Optional.empty();
8482
}
8583

8684
@Override

0 commit comments

Comments
 (0)