我确实有一个存储库
@Repository
public interface PointOfInterestRepository extends GraphRepository<Poi> {
// currently empty
}
没有定义自定义方法。因此,我使用了预定义的类似save(T... entities)
的内容。
我的Poi
类如下
@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*/
}
带有用于字段的getter。
目前,我可以将这些Pois保存到neo4j并将其检索回来,但当我尝试通过密码处理数据库中的这些节点时,字段似乎没有映射到neo4 j属性。
我认为spring-data-neo4j会将我的类字段转换为neo4j图属性。我错了吗
注意:save
调用似乎工作得很好。之后,我可以看到数据库中的节点,然后调用findAll()
将正确返回所有保存的节点(Pois)和所有正确的值。但不知何故,在数据库中,我看不到任何属性/字段。
问题在于最后的字段。从图中加载时,SDN将无法将值写回实体,因为这些字段是最终字段(SDN将仅使用默认的无参数构造函数),因此不支持最终字段。移除决赛应该可以解决这个问题。