brunoid
brunoid

Reputation: 2211

Neo4j/SDN warining: No identity field found for class of type for exception class

In my Neo4j/Spring Data Neo4j project I have a following exception class:

public class CriterionNotFoundException extends NotFoundDomainException {

    private static final long serialVersionUID = -2226285877530156902L;

    public CriterionNotFoundException(String message) {
        super(message);
    }

}

During application startup I see a following WARN:

WARN  o.s.d.n.m.Neo4jPersistentProperty - No identity field found for class of type: com.example.domain.dao.decision.exception.DecisionAlreadyExistsException when creating persistent property for field: null

Why Neo4j/SDN is looking for identity field in this class ? How to correctly configure my application in order to skip this warning ?

Upvotes: 3

Views: 1457

Answers (2)

OzgurH
OzgurH

Reputation: 453

One way "to correctly configure [your] application" would be add EnableNeo4jRepositories and EntityScan annotations to your SpringBootApplication (or your config bean) as mentioned here and specify the names of your packages with Neo4J relevant classes.

I've debugged the SDN/Neo4j code only for 5 minutes, so my guesses may be off, but, I believe those warnings are generated when you don't specify packages to scan for your entities, and repositories. I'm guessing in that case SpringBoot+Neo4J-mapping scans each and every class in your project, and if a class has some fields, but nothing resembling an "id" field, it spits this warning. (So adding a Long id field to the classes with warnings may be another (yes, very ugly) work-around as well)

I've seen those warnings vanished when I tried explicitly specifying package names in my project using SpringBoot 2.0.6 + spring-data-neo4j 5.0.11.

Upvotes: 1

Luanne
Luanne

Reputation: 19373

You can ignore this warning- this is produced by SDN when building metadata Spring Data REST integration. It should not be doing this for Exceptions of course, and we'll have this fixed.

Upvotes: 5

Related Questions