【发布时间】:2022-01-04 08:02:31
【问题描述】:
我有一个存储库类,我在其中扩展了 JPARepository 并创建了一个从表中获取记录列表的查询。
ICA ica = null;
ica = brRepository.findByNameAndId(name , id);
现在当这个ica = brRepository.findByNameAndId(name , id);被执行并且假设表中没有记录ica的值是什么
只会为空吗?
基本上,我想将ica 与 null 进行比较,如果它为 null,则记录其他内容。
是比较正确的方法还是安全操作?
if(ica == null){
System.out.println("Null");
}
else{
System.out.println("there is one record");
}
【问题讨论】:
-
"只会为 null 吗?" - 我不完全确定您的意思,但为什么不试试呢?
标签: java spring-boot spring-data-jpa