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 []