Custom Spring Data Repository返回LinkedHashMap而不是null

时间:2018-06-07 15:19:37

标签: spring spring-data spring-data-rest

我正在尝试将spring项目(而不是spring boot)中的依赖项从spring 4.2.5.RELEASE升级到4.3.17.RELEASE,我们的第一个测试发现了以下更改的行为: 当自定义存储库实现返回null时,该方法实际上返回一个空的LinkedHashMap。 使用自定义存储库实现我的意思是这样的:

public class PersonRepositoryImpl implements PersonRepositoryCustom

当然,我们有标准存储库:

public interface PersonRepository extends CrudRepository<Person, Long>, PersonRepositoryCustom

这是PersonRepositoryImpl中的一个简单示例方法:

@Override
public Map<String, Object> getSomeElement() {
    return null;
}

但是在我们的测试中,我们发现我们没有得到一个null对象,而是一个空的LinkedHashMap对象。在我们更改弹簧和弹簧数据版本之前,这是不同的。这是一个错误吗?这可能以某种方式配置不同吗?我们的代码中有很多空检查,找到所有这些实例需要付出很多努力。

更新1: 我更多地挖掘并发现依赖

org.springframework.data:spring-data-jpa:1.10.4

是罪魁祸首。确切地说,应该是spring-data-commons依赖的这种变化(spring-data-jpa带来的) https://github.com/spring-projects/spring-data-commons/commit/c554065049dd9a77cc28de190a16083e26df5c07

由于Spring 4.3.17不需要这个spring-data-jpa版本,我们暂时只停留在org.springframework.data:spring-data-jpa:1.10.3。我在Spring JIRA中为此创建了一个问题: https://jira.spring.io/browse/DATACMNS-1337

0 个答案:

没有答案
相关问题