0
votes

I have a Neo4J database containing nodes with label "Company" with name properties:

neo4j-sh (?)$ match (n:Company {name:"SmallCo"}) return n;
+--------------------------+
| n                        |
+--------------------------+
| Node[16]{name:"SmallCo"} |
+--------------------------+
1 row

I am trying to make a web application using Spring Data.

My repository class:

@RepositoryRestResource(collectionResourceRel = "companies", path = "companies")
public interface CompanyRepository extends GraphRepository<Company> {
    Company findByName(@Param("name") String name);
 ...

Company domain object class:

@JsonIdentityInfo(generator=JSOGGenerator.class)
@NodeEntity
public class Company {
    @GraphId Long id;

    String name; 

 public String getName() {
        return name;
    }

Service class:

@Service
@Transactional
public class InfoService {

    @Autowired CompanyRepository companyRepository;

Main:

@Configuration
@Import(MyNeo4jConfiguration.class)
@RestController("/")
public class SampleApplication extends WebMvcConfigurerAdapter {

    public static void main(String[] args) throws IOException {
        final Logger logger = LoggerFactory.getLogger(Neo4jConfiguration.class);
        SpringApplication.run(SampleApplication.class, args);
    }

    @Autowired
    InfoService infoService;

However, when I run the application, this query doesn't return anything:

http://localhost:8080/companies/search/findByName?name=SmallCo

If I run it through the the debugger, the query method throws a NullPointerException. What am I missing here?

EDIT:

I see this warning on the console:

14:17:28.432 [main] WARN  o.s.d.n.m.Neo4jPersistentProperty - Owning ClassInfo  is null for field: java.lang.String     main.java.info.spring.data.neo4j.domain.Company.name and propertyDescriptor: org.springframework.beans.GenericTypeAwarePropertyDescriptor[name=name]

The stack trace is not helpful - it is just []

1
Which version of Spring data? Can you post the full stacktrace? - Luanne
I am using the artifact "spring-data-neo4j" with version 4.0.0.RELEASE. - Bob Bobson The Third Esq.
I see this on the console: INFO o.s.d.n.config.Neo4jConfiguration - Intercepted exception - Bob Bobson The Third Esq.

1 Answers

0
votes

The issue was that I had forgotten to update the package name in the configuration class in the SessionFactory constructor.