i've got Social model :
import java.util.Set;
import org.neo4j.graphdb.Direction;
import org.springframework.data.neo4j.annotation.Fetch;
import org.springframework.data.neo4j.annotation.GraphId;
import org.springframework.data.neo4j.annotation.Indexed;
import org.springframework.data.neo4j.annotation.NodeEntity;
import org.springframework.data.neo4j.annotation.RelatedTo;
@NodeEntity
public class Social {
@GraphId
private Long id;
@Indexed
private Long userId;
@RelatedTo(type="FRIEND", direction=Direction.BOTH)
@Fetch private Set<Social> friends;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Set<Social> getFriends() {
return friends;
}
public void setFriends(Set<Social> friends) {
this.friends = friends;
}
public void addFriend(Social social){
this.friends.add(social);
}
}
and repository :
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.neo4j.repository.RelationshipOperationsRepository;
import com.msci.travelpad.entities.Social;
public interface SocialRepository extends GraphRepository<Social>, RelationshipOperationsRepository<Social> {
}
but when i would to find social node by userId using :
public Social findByUserId(Long userId) {
return socialRepository.findByPropertyValue("userId", userId);
}
findByUserId always return null.
Did you try to implement your own find method in the repository like:
Iterable<Social> findByUserId(Long userId);
Are the indexes created correctly (see Null return using GraphRepository from Spring Data for Neo4j )?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.