- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Hibernate 从 Postgresql DB 获取数据,但在尝试将 EMPTY 或 NULL 作为 Long 值列表传递给查询时总是出现此错误:
@Repository
public interface ProductRepository extends JpaRepository<Category, Long> {
@Query(nativeQuery = true,
value = "SELECT * FROM Products p " +
"WHERE (COALESCE(:#{#param.colors}) IS NULL OR p.color IN (:#{#param.colors}))")
List<Product> findFiltered(@Param("param") ProductFilterParams params);
}
(注意:由于请求复杂,我使用原生查询)
ProductFilterParams 看起来像:
@Data
public class ProductFilterParams {
private List<Long> colors;
...other product filters...
}
所以我的想法是按颜色过滤产品(效果很好)或显示所有产品,如果没有颜色过滤器(这里我得到这个错误)。
当我将 null 作为颜色日志传递时:
binding parameter [1] as [LONGVARCHAR] - [null]
ERROR: operator does not exist: bigint = character varying
或者当我尝试传递空列表时:
*** NO BINDING LOG AT ALL ***
ERROR: syntax error at or near ")"
我不知道为什么会出现这个错误以及如何解决它。我尝试了一些来自 web/stackoverflow 的谷歌搜索答案,但所有这些都是针对 HQL 的,无法针对 native 查询修复它。
最佳答案
实际上,hibernate 文档 says :
IN
predicates performs a check that a particular value is in a list of values. Its syntax is:
in_expression ::= single_valued_expression [NOT] IN single_valued_list
single_valued_list ::= constructor_expression | (subquery) | collection_valued_input_parameter
constructor_expression ::= (expression[, expression]*)
The list of values can come from a number of different sources. In the
constructor_expression
andcollection_valued_input_parameter
, the list of values must not be empty; it must contain at least one value.
但是,正如所解释的那样here它在 hibernate 5.4.10 中被更改。但是当您使用 hibernate 5.3.7.final 时,您应该在查询之外移动检查集合是否为空。
顺便说一句,使用COALESCE是没有意义的具有一个参数的函数。
关于java - 错误 : operator does not exist: bigint = character varying for empty list of long,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65932668/
我将数据库从 sqlite 更改为 postgresql 以用于我网站的生产,但出现此错误。当我在本地使用 sqlite 时,它没有出现这个错误。使用 Django。 ProgrammingErr
对于同一资源的请求,HTTP 服务器有时使用 Vary: * 有时使用 Vary: Foo 响应是否有任何原因? 缓存应该做什么,如果在收到(和缓存)两个响应后,它会收到一个带有匹配的 Foo hea
对于我的应用程序,我创建了一个 SQL 文件补丁以将列 user_name 添加到现有表中: CREATE OR REPLACE FUNCTION add_col( _tbl VARCHAR,
我希望有人能帮忙 1) 在小平面图中跨面板改变 x 轴的格式 2) 仅在刻面左侧显示黄土较光滑。 左边是更长的历史,右边是过去十二个月。 真实数据集有更多数据(更多时间和更多变量),因此这些问题变得更
当我尝试在数组数组中搜索一个数组值时出现上述错误。我的代码: sequelize.define('room', { 'id' : {'type' : DataTypes.INTEGER
昨天我们将 PostgreSQL 数据库升级到了 9.1.3 版本。我们认为我们已经测试并准备好了一切,但我们错过了一个功能。它返回这样的表类型: CREATE OR REPLACE FUNCTION
我是 SO 和 postgres 的新手所以请原谅我的无知。尝试使用类似于本文中的解决方案在 postgres 中获取图形的集群 Find cluster given node in PostgreS
我在 MacBook Pro 上使用 GLFW 3 和 OpenGL 4 + GLSL 4。 启动程序时出现以下语法错误: ERROR: 0:5: 'varying' : syntax error s
上下文 我正在构建一个针对 5.0+ 的 Android 应用程序,它使用 BLE 连接到多个外围设备。这些外围设备中的每一个都有许多(~10)个特性。理想情况下,我想订阅这些特征中每一个特征的更改通
根据我对 this question 的回答中所解释的理解您可以为您想要的任何设备调整 Storyboard 上的任何组件的大小,这就是问题发生的地方..我有一张图片,它的常规分辨率是:353x229
我想确保我的某些回复不会被任何人缓存。建议的选项之一是设置 Vary: *。 不幸的是,如果我添加 add_header "Vary""*";,启用了 gzip 支持的 nginx 会返回两个 Var
我试图弄清楚为什么我的Magento 2.2.6商店显示标题: vary: Accept-Encoding,User-Agent 问题是“用户代理”使我的缓存无法正常工作。 我的商店的 build 方
最近,我尝试在该领域之前进行的工作的基础上创建一个股票市场预测程序,其中通过 Python 中的 Keras 模块创建的神经网络接收来自 Quandl 的调整后的股票价格信息,利用上述信息来训练自己。
我正在使用 moment.js 和 Moment Timezone 来处理不同时区的 ISO 日期。然而,我一定是做错了什么,因为我从解析中得到的结果是完全错误的,即使据我所知我并没有做任何奇怪的事情
在 Android Studio 2.2.2 中,我在 AndroidManifest.xml 文件中有一个错误 Resources referenced from the manifest cann
在我的用户模型上运行一个简单的语句,但不断收到有关运算符与任何给定参数不匹配的错误。我以前从未遇到过这样的事情,也不知道如何处理。我知道我可能必须添加类型转换,但在我的 POSTGRES 数据库中,列
我因异常而失去理智,我需要你的帮助。 我已经将查询写入映射器,该映射器根据两个条件从表中检索记录:列表中的“位置”和另一个列表中的“技能”。 所以,基本上,如果用户选择了不止一种技能来查找,查询将恢复
我需要帮助来查看以下查询,我有如下表格: CREATE TABLE "MasterDivision" ( "DivisionID" bigserial NOT NULL, "Divis
我的 postgres 数据库表有一个列位置是字符 varying[]。在我的表的 nestjs 实体中,我有以下位置列- @Column("character varying",{array:tr
我的模型有一个 SlugField。当我尝试将 slug 字段设置为比字段的 max_length 参数(默认为 50)长的字符串来保存此模型的实例时,我从 Postgresql 收到以下错误:val
我是一名优秀的程序员,十分优秀!