使用spring-data-neo4j时如何修复java.lang.IllegalStateException

时间:2019-01-15 21:48:11

标签: spring-boot neo4j spring-data spring-data-neo4j

我有一个简单的测试项目,其中使用spring boot版本:2.1.0.RELEASE(https://github.com/tomkasp/neo4j-playground/blob/master/src/main/java/com/athleticspot/neo4jplayground/domain/AthleteRepository.java)来检查spring-data-neo4j

spring-data-neo4j(版本:5.1.4.RELEASE)依赖项由spring-boot-starter-data-neo4j注入。

我的目标是创建一个存储库方法,该方法可使用包含和忽略大小写功能来获取数据。为此,我在存储库中创建了以下方法:

public interface AthleteRepository extends CrudRepository<Athlete, Long> {

    List<Athlete> findByNameContainingIgnoreCase(String name);

}  

运行上述功能时,我得到:

java.lang.IllegalStateException: Unable to ignore case of java.lang.String types, the property 'name' must reference a String
at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.data.neo4j.repository.query.filter.PropertyComparisonBuilder.applyCaseInsensitivityIfShouldIgnoreCase(PropertyComparisonBuilder.java:101) ~[spring-data-neo4j-5.1.2.RELEASE.jar:5.1.2.RELEASE]

spring-data-neo4j是否不同时支持Containing和IgnoreCase?我想念什么吗?

1 个答案:

答案 0 :(得分:0)

目前看来这是不可能的,因为引用的org.springframework.data.neo4j.repository.query.filter.PropertyComparisonBuilder似乎只允许忽略“ SIMPLE_PROERTY”的大小写(等于)。请参见同一类中的方法canIgnoreCase

private boolean canIgnoreCase(Part part) {
    return part.getType() == SIMPLE_PROPERTY && String.class.equals(part.getProperty().getLeafType());
}

修正是在5.2版春季版(摩尔)中发布的:https://jira.spring.io/browse/DATAGRAPH-1190