Spring Data integration for ArangoDb gives back empty result list on queries

35 views
Skip to first unread message

Andrea Taini

unread,
Feb 3, 2020, 7:34:22 PM2/3/20
to ArangoDB

When I use queries from method names with ArangoDb and Spring Data integration I always get empty lists. What is the problem in the way I use? This is an example.

These are the Entities:

Authorization:

@Document("authorizations")
@Data // (Lombok)
public class Authorization {

  @Id
  private String id;

  private String caption;

  @Relations(edges = com.picktur.server.relations.UserAuthorized.class, lazy = true)
  private User user;

}

User:

@Document("users")
@Data @NoArgsConstructor // (Lombok)
public class User {

  @Id
  private String id;

  private String username;

  @Relations(edges = com.picktur.server.relations.UserAuthorized.class, lazy = true)
  private Collection<Authorization> authorizations;

}

Authorization Repository:

public interface AuthorizationRepo extends ArangoRepository<Authorization, String> {

  Iterable<Authorization> findAllByUser(User user);

}

Edge between User and Authorization:

@Edge
@Data
public class UserAuthorized {

  @Id
  private String id;

  @From
  private User user;

  @To
  private Authorization authorization;

public UserAuthorized( User user, Authorization authorization) {
    this.authorizedPhoto = user;
    this.authorization = authorization;
}

}

Repository for UserAuthorized Egde:

public interface UserAuthorizedRepo extends ArangoRepository<UserAuthorized, String> {

}

Data Persistency logic:

    User user = get_user_from_security_context();
    Authorization authorization = new Authorization();        
    authorization.setUser(user);
    ...
    authorization = authorizationRepo.save(authorization);

    UserAuthorized userAuthorized = new UserAuthorized(user, authorization);
    userAuthorizedRepo.save(userAuthorized);

Query that has empty result:

Iterable<Authorization> authorizations = authorizationRepo.findAllByUser(user);

All the documents and edges exist in DB but the result is empty.

Michele Rastelli

unread,
Feb 12, 2020, 10:18:15 AM2/12/20
to ArangoDB
Reply all
Reply to author
Forward
0 new messages