I replied here: https://stackoverflow.com/a/60191467/553341

On Tuesday, 4 February 2020 01:34:22 UTC+1, Andrea Taini wrote:
>
> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/arangodb/1c1a7522-4d06-4f6f-8512-f509c9c4297a%40googlegroups.com.

Reply via email to