Neo4J OGM v2.0.4的代码读取(文件org / neo4j / ogm / context / GraphEntityMapper.java,第313-339行):
// If the source has a writer for an outgoing relationship for the rel entity, then write the rel entity on the source if it's a scalar writer
ClassInfo sourceInfo = metadata.classInfo(source);
RelationalWriter writer = entityAccessStrategy.getRelationalWriter(sourceInfo, edge.getType(), Relationship.OUTGOING, relationshipEntity);
if (writer == null) {
logger.debug("No writer for {}", target);
} else {
if (writer.forScalar()) {
writer.write(source, relationshipEntity);
mappingContext.registerRelationship(new MappedRelationship(edge.getStartNode(), edge.getType(), edge.getEndNode(), edge.getId(), source.getClass(), ClassUtils.getType(writer.typeParameterDescriptor())));
} else {
oneToMany.add(edge);
}
}
//If the target has a writer for an incoming relationship for the rel entity, then write the rel entity on the target if it's a scalar writer
ClassInfo targetInfo = metadata.classInfo(target);
writer = entityAccessStrategy.getRelationalWriter(targetInfo, edge.getType(), Relationship.INCOMING, relationshipEntity);
if (writer == null) {
logger.debug("No writer for {}", target);
} else {
if (writer.forScalar()) {
writer.write(target, relationshipEntity);
} else {
oneToMany.add(edge);
}
}
但是不应该读第一条日志消息
logger.debug("No writer for {}", target);
代替?我收到一条令人困惑的日志消息,上面写着我的一类没有作家,但那个班级肯定有作家。我问,因为我想确保我没有忽视任何事情。
干杯谢谢,
斯蒂芬
答案 0 :(得分:1)
当您的关系实体是集合时,您可能会看到此调试消息。映射器首先尝试为单个关系查找关系编写器,然后返回到集合。所以除非你发现你的关系实体没有被持久化,否则你可能没什么可担心的。