Ed, that connection query is a very common query in a graph database. I have a query that would return a list of connections of connections from a person.
You just write a Cypher query and it returns a full list of them all populated. It is just one query. And as far as saving, it is just changing those objects within a transaction.
Here is what my repository method looks like
Code:
@Query("start user=node({0}) " +
"match user-[:"+ User.FRIEND+"]->friends-[:"+ User.FRIEND+"]->friendsOfFriends " +
"return friendsOfFriends " +
"order by count(*) desc, friendsOfFriends.lastName asc")
public Page<User> findFriendsOfFriends(User user, Pageable pageable);
and in my Service I just call that method and I get a list of Users fully populated. (Note I use ThreadLocal to store page size and number and get it in my service method, but I am not showing that code here, also the User is the user logged in, so it already in my Spring Security Context. Also not shown is the creation of my ListOfDomains object, but none of that is necessary to demonstrate how simple a query like that is. No fetch depth needed.)
Code:
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserRepository userRepository;
@Transactional
public ListOfDomains<User> findFriendsOfFriends() {
Page<User> foff = userRepository.findFriendsOfFriend(userRepository.getUserFromSession(), PageRequestHandler.getPageRequest());
// Loop through Users and change properties.
…….
}
}
At this time, should these questions be posted in another topic. They are very off topic from the original thread I created.
Thanks
Mark
Mark