Spring 数据 Neo4j 未将 Class 字段映射到节点属性
Spring Data Neo4j not mapping Class fields to node properties
我有一个存储库
@Repository
public interface PointOfInterestRepository extends GraphRepository<Poi> {
// currently empty
}
没有定义自定义方法。所以我使用预定义的 save(T... entities)
之类的东西。
我的 Poi
class 如下
@NodeEntity(label = "PointOfInterest")
public class Poi {
@JsonIgnore
@GraphId
Long neo4jId;
@JsonManagedReference("node-poi")
@JsonProperty("node")
@Relationship(type = "BELONGS_TO", direction = Relationship.UNDIRECTED)
private Node node;
@JsonProperty("id")
@Property(name = "poiID")
private final String id;
@JsonProperty("uris")
@Property(name = "uris")
private final Set<URI> correspondingURIs = new HashSet<>();
/* Some more stuff I skip here*/
}
具有字段的吸气剂。
目前我能够将此类 Pois 保存到 neo4j 并将它们取回,但是当我尝试通过密码 处理数据库中的这些节点时,这些字段似乎没有映射到 neo4j属性.
我认为 spring-data-neo4j 会将我的 class 字段转换为 neo4j 图形属性。我错了吗?
注意: save
调用似乎工作得很好。之后我可以在数据库中看到节点,然后调用 findAll()
将 return 我所有保存的节点 (Pois) 正确地具有所有正确的值。但不知何故,在数据库中,我看不到任何 properties/fields.
问题是最终字段。当从图中加载时,SDN 将无法将值写回实体,因为这些字段是最终字段(并且 SDN 将仅使用默认的无参数构造函数),因此不支持最终字段。
删除决赛应该解决这个问题。
我有一个存储库
@Repository
public interface PointOfInterestRepository extends GraphRepository<Poi> {
// currently empty
}
没有定义自定义方法。所以我使用预定义的 save(T... entities)
之类的东西。
我的 Poi
class 如下
@NodeEntity(label = "PointOfInterest")
public class Poi {
@JsonIgnore
@GraphId
Long neo4jId;
@JsonManagedReference("node-poi")
@JsonProperty("node")
@Relationship(type = "BELONGS_TO", direction = Relationship.UNDIRECTED)
private Node node;
@JsonProperty("id")
@Property(name = "poiID")
private final String id;
@JsonProperty("uris")
@Property(name = "uris")
private final Set<URI> correspondingURIs = new HashSet<>();
/* Some more stuff I skip here*/
}
具有字段的吸气剂。
目前我能够将此类 Pois 保存到 neo4j 并将它们取回,但是当我尝试通过密码 处理数据库中的这些节点时,这些字段似乎没有映射到 neo4j属性.
我认为 spring-data-neo4j 会将我的 class 字段转换为 neo4j 图形属性。我错了吗?
注意: save
调用似乎工作得很好。之后我可以在数据库中看到节点,然后调用 findAll()
将 return 我所有保存的节点 (Pois) 正确地具有所有正确的值。但不知何故,在数据库中,我看不到任何 properties/fields.
问题是最终字段。当从图中加载时,SDN 将无法将值写回实体,因为这些字段是最终字段(并且 SDN 将仅使用默认的无参数构造函数),因此不支持最终字段。 删除决赛应该解决这个问题。