【问题标题】:How to fix java.lang.IllegalStateException when using spring-data-neo4j使用 spring-data-neo4j 时如何修复 java.lang.IllegalStateException
【发布时间】:2019-06-09 23:11:18
【问题描述】:

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

spring-data-neo4j (version: 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 一起使用吗?我错过了什么吗?

【问题讨论】:

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


【解决方案1】:

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

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

Spring 5.2 (Moore) 即将修复:https://jira.spring.io/browse/DATAGRAPH-1190

【讨论】:

  • 谢谢,这很有意义
猜你喜欢
  • 1970-01-01
  • 2015-09-15
  • 2013-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多