简体   繁体   English

Spring JPA 在所有值都是 null 的情况下按示例查询返回错误

[英]Spring JPA Query By Example return error in case all values are null

I'm using Spring JPA Query By Example to allow dynamic filters.我正在使用 Spring JPA Query By Example 来允许动态过滤器。 However I notice that if the example object has all the values set a null, the example query returns all the values of the table.但是我注意到,如果示例 object 将所有值设置为 null,则示例查询将返回表的所有值。

I cannot add mandatory field, since the queries must be complete dynamic, also pagination is not an option.我不能添加必填字段,因为查询必须是完全动态的,分页也不是一个选项。

Therefore I wanted to ask if there is a way to tell JPA that if all the values in the probe example are null to return a error o execute some kind of fall back operation.因此,我想问是否有办法告诉 JPA 如果探针示例中的所有值都是 null 以返回错误或执行某种回退操作。

No, such a setting does not exist, you'd have to check that yourself up front.不,这样的设置不存在,你必须自己检查一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM