对嵌套实体上的属性使用查询派生时"java.lang.IllegalArgumentException: Cannot query by nested property"



这是一个后续问题:引用另一个聚合与子实体

我有以下聚合:

Evaluation (root)
|
|__Employee (entity)
|  |_SupervisorId (value object)
|
|__Year (value object)
|
|__ExpiryDate (value object)

我有一个EvaluationRepository接口,在那里我使用查询派生来读取Evaluation。方法如下:

Set<Evaluation> findAllByYearAndExpiryDateIsNullAndEmployee_SupervisorId(Integer year, Long supervisorId);

我得到这个例外:

Caused by: java.lang.IllegalArgumentException: Cannot query by nested property: employee.supervisorId
at org.springframework.data.jdbc.repository.query.JdbcQueryCreator.validateProperty(JdbcQueryCreator.java:142)
at org.springframework.data.jdbc.repository.query.JdbcQueryCreator.validate(JdbcQueryCreator.java:132)
at org.springframework.data.jdbc.repository.query.PartTreeJdbcQuery.<init>(PartTreeJdbcQuery.java:109)
at org.springframework.data.jdbc.repository.support.JdbcQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JdbcQueryLookupStrategy.java:119)
at org.springframework.data.jdbc.repository.support.JdbcQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JdbcQueryLookupStrategy.java:205)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:103)
... 136 more

这是JdbcQueryCreator中抛出异常的行:

if (!path.getParentPath().isEmbedded() && path.getLength() > 1) {
throw new IllegalArgumentException(
String.format("Cannot query by nested property: %s", path.getRequiredPersistentPropertyPath().toDotPath()));
}

当我通过@query编写自定义查询时,它是有效的。这里的查询派生有什么问题?

这里的查询派生有什么问题?

问题很简单,这还没有为Spring Data JDBC实现。

最新更新