java.lang.IllegalStateException:没有主SDN标签..(即以_开头的标签)

时间:2014-05-03 23:13:25

标签: neo4j spring-data-neo4j

我正在尝试使用SDN 3.0.2和Neo4j 2.0.1创建节点

以下是我的工作方式:

query = "MATCH (root:Date) " +
    "CREATE UNIQUE (root)<-[:`"+year+"`]-(y:Year {value:'"+year+"Y"+"'})" +
    "<-[:`"+month+"`]-(m:Month {value:'"+year+"Y"+month+"M"+"'})" +
        "<-[:`"+day+"`]-(d:Day {value:'"+year+"Y"+month+"M"+day+"D"+"'}) " +
    "RETURN d";
Iterable<Day> days = template.query(query, map).to(Day.class);
Transaction tx = template.getGraphDatabaseService().beginTx();
Set<Day> result = IteratorUtil.asSet(days);
tx.close();

以这种方式执行,我java.lang.IllegalStateException: No primary SDN label exists .. (i.e one with starting with _)

获得Set<Day> result = IteratorUtil.asSet(days)

如果删除Set<Day> result = IteratorUtil.asSet(days),它会正常工作 但实际上我需要返回结果,这是一个独特的Day实体。

我错过了什么吗?

这是Day POJO:

@NodeEntity
@TypeAlias(value="Day")
public class Day implements Serializable {
    private static final long serialVersionUID = 1L;
    @GraphId 
    private Long nodeId;
    @Indexed(unique=true)
    private String id;

    //@Indexed(indexType=IndexType.FULLTEXT, indexName = "days")
    private String value;

    @RelatedTo(type="NEXT_DAY", direction = Direction.BOTH)
    private Day next;

    private Month month;

        //Other relationships to different entities
        //Getters & setters
        //Empty & with params constructors

}

1 个答案:

答案 0 :(得分:1)

我必须在密码查询中添加_Label:

query = "MATCH (root:Date) " +
    "CREATE UNIQUE (root)<-[:`"+year+"`]-(y:Year:_Year {value:'"+year+"Y"+"'})" +
    "<-[:`"+month+"`]-(m:Month:_Month {value:'"+year+"Y"+month+"M"+"'})" +
        "<-[:`"+day+"`]-(d:Day:_Day {value:'"+year+"Y"+month+"M"+day+"D"+"'}) " +
    "RETURN d";