有人可以解释一下相应的Cypher Query语法,以便从下面提到的Repository查询中获得以下结果吗?以下提到的团队名称已保存到存储库中。
我被建议下面的Cypher最终进入NPE。 Neo4j: Native Java API(or equivalent cypher query) in Spring Data Neo4j
//Repository
public interface TeamRepository extends GraphRepository<Team>
{
@Query("start team=node:teamName({0}) RETURN team")
List<Team> findByTeamName(String query);
}
以下调用在调用时抛出NPE,如下所示:
teamRepository.findByTeamName("The Los Angeles Will be Playing in a state of Golden");
的NullPointerException:
Exception in thread "main" java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:675)
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:690)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
at com.directv.service.Sports.main(Sports.java:134)
Caused by: java.lang.NullPointerException
at org.apache.lucene.util.SimpleStringInterner.intern(SimpleStringInterner.java:54)
at org.apache.lucene.util.StringHelper.intern(StringHelper.java:39)
at org.apache.lucene.index.Term.<init>(Term.java:38)
at org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser.java:643)
答案 0 :(得分:0)
经过一些试验和错误,我能够解决这个问题。正如@Michael Hunger指出的那样,这是查询中嵌入空格字符的问题。适当的查询是:
@Query("START team=node:teamName('teamName:(*The Los Angeles Will be Playing in a state of Golden*)') RETURN team")