0

我正在使用 4.0.0.M1

    Organisation microsoft = organisations.findByName("Microsoft");
    if (microsoft == null) {
        microsoft = new Organisation("Microsoft");
        organisations.save(microsoft);
    }

    Organisation apple = organisations.findByName("Apple");
    if (apple == null) {
        apple = new Organisation("Apple");
        organisations.save(apple);
    }

    Organisation checkMicrosoft = organisations.findByName("Microsoft");

在我的案例中,最后一行崩溃,因为返回了 2 个结果并且 Neo4J 试图返回一个Iteratable

出于某种原因,findByName('Microsoft')行为与findAll();相同

界面

public interface Organisations extends GraphRepository<Organisation> {

   Organisation findByName(String name);

}

节点实体

@NodeEntity
public class Organisation {

    public Organisation() {
        // Empty Constructor
    }

    public Organisation(String name) {
        this.name = name;
    }

    @GraphId
    Long id;

    @Property
    String name;
}

这是一个错误,还是我做错了什么?

4

1 回答 1

1

这是 4.0.0-M1 中的一个错误。它在快照版本 4.0.0.BUILD-SNAPSHOT 中修复

您需要将此 repo 添加到您的 pom 以获取它:

    <repository>
        <id>spring-libs-snapshot</id>
        <url>http://repo.spring.io/libs-snapshot</url>
    </repository>

希望这可以帮助

于 2015-05-27T21:50:47.257 回答