springboot @Relationship 用法问题
发布于 3 年前 作者 batman123 2460 次浏览 来自 问答

在我的程序中遇到了这样的问题,请大佬解答 node entity中使用@Relationship修饰关系属性时可以成功注入,修饰节点属性时属性为null

ogm:3.2.9 spring-data-neo4j:4.0.0 在我的程序中是这样定义的,只展示关键信息,其他省略

@NodeEntity(value = “cabinet”) @NoArgsConstructor(force = true) public class Cabinet {

[@Relationship](/user/Relationship)(type = "cabinet_contain", direction = "UNDIRECTED")
@JsonIgnoreProperties(value = "from")
List<CabinetContain> cabinetContains;

[@Relationship](/user/Relationship)(type = "cabinet_contain", direction = Relationship.UNDIRECTED)
List<Framework> frameworks;

}

@RelationshipEntity(type = “cabinet_contain”) public class CabinetContain {

@Id
@GeneratedValue
private Long id;

@StartNode
private Cabinet from;

@EndNode
private Framework to;

}

如上,CabinetContains查询有值,frameworks为null

回到顶部