java - org.jdbi.v3.core.statement.UnableToCreateStatementException:查询声明无时提供了多余的命名参数
问题描述
@SqlQuery("Select id from user where type in (<CAST(userType as user_type[])>)")
List<Long> getUserIdsByListOfTypes(@BindList("userType") List<User.UserType> userType);
我想从用户类型列表中获取 Id 列表。
这里 User.UserType 是一个枚举。在方法(getUserIdsByListOfTypes)中,我传递了枚举类型列表的参数(userTypes)。
我无法理解查询中的问题出在哪里。
解决方案
我没有采用枚举类型列表,而是采用了字符串列表。
@SqlQuery("Select id from user where type::text in (<userType>)")
List<Long> getUserIdsByListOfTypes(@BindList("userType") List<String> userType);
推荐阅读
- r - R - 是否可以在没有数据的情况下保存模型定义?
- c - 如何在C中正确打印结构类型数组的所有元素?
- python - 使用块从 MySQL 数据库中检索大数据并保存它们 Dataframe Pandas
- c++ - Visual Studio Code 在哪里查找 includePath(C/C++ 扩展)
- for-loop - 对于/在探针中。object.variable 和 object[variable] 有什么区别?
- android - SharedPreferences 不保存布尔属性
- python - 在 Python 中,我可以在运行时更改类的结构吗?
- python - 关闭 PIR 运动传感器
- excel - 如何使用vba宏更新excel中列的过滤单元格的值?
- angular - 我无法根据类别获取课程