Stephan Neuhaus
Stephan Neuhaus

Reputation: 128

Neo4J Java can't load relations: "no writer for...": Neo4J OGM logging error?

the code for Neo4J OGM v2.0.4 reads (file org/neo4j/ogm/context/GraphEntityMapper.java, lines 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);
        }
    }

But shouldn't the first log message read

logger.debug("No writer for {}", target);

instead? I'm getting a confusing log message which says that a class of mine has no writers, but where that class definitely does have a writer. I'm asking because I want to make sure that I didn't overlook anything.

Cheers and thanks,

Stephan

Upvotes: 1

Views: 205

Answers (1)

Luanne
Luanne

Reputation: 19373

It is possible that you see this debug message when your relationship entities are collections. The mapper attempts to find a relational writer for single relationships first and then falls back to collections. So it's probably nothing you should worry about unless you find your relationship entities not being persisted.

Upvotes: 1

Related Questions