Java spring-data-neo4j findByPropertyValue方法是否始终返回null?

Java spring-data-neo4j findByPropertyValue方法是否始终返回null?,java,spring,neo4j,spring-data,spring-data-neo4j,Java,Spring,Neo4j,Spring Data,Spring Data Neo4j,我有一个社会模式: 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 or

我有一个社会模式:

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);
    }
}
findByUserId始终返回null


您是否尝试在存储库中实现自己的查找方法,如:

Iterable<Social> findByUserId(Long userId);
Iterable findByUserId(长用户id);

索引创建是否正确(请参阅)?

我运行了您的代码,没有任何问题。您需要在调用findByUserId()方法的地方发布代码。
public Social findByUserId(Long userId) {
    return socialRepository.findByPropertyValue("userId", userId);
}
Iterable<Social> findByUserId(Long userId);