I have two entities like Users and Accounts. User node related to Account node with any of the 20 relationships. Please find the sample image design attached
i need to search accounts for corresponding users using any of the 20 relationships. i used the cypher query for retriving user details and the accounts.. Relationship between the two entity will be either any one of the 20 relationships . so i can't annotate the @RelationshipEntity type value. Please find the code for example User.java
public class User
{
private Long id;
String fulltextsearch;
String user_id;
String status;
@Relationship(type = "perm")
List<Acronym> acronym;
.....
...
}
Acronym.java
@JsonIdentityInfo(generator=JSOGGenerator.class)
@RelationshipEntity
public class Acronym {
@GraphId
Long id;
String acronym;
@StartNode
private User user;
@EndNode
private Account account;
....
....
}
Userrepository.java
@RepositoryRestResource(collectionResourceRel = "User", path = "User")
public interface Userrepository extends GraphRepository<User> {
User findByLogin(@Param("login") String login);
@Query("MATCH p=(user:User)-[r*0..1]->(account) WHERE user.login =~('(?i).*'+{Login}+'.*') RETURN p")
Collection<User> findByloginContaining(@Param("login") String login);
}
i tried creating objects for each relationship (ie 20 relationship object.). i'm not sure if that correct way to get the value. Could anyone please help me to know to fetch the relationships against the account? it always retrives as null.
Thanks in advance.