首页 > 解决方案 > 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)。
我无法理解查询中的问题出在哪里。

标签: javaspring-bootjdbi3

解决方案


我没有采用枚举类型列表,而是采用了字符串列表。

@SqlQuery("Select id from user where type::text in (<userType>)")   
List<Long> getUserIdsByListOfTypes(@BindList("userType") List<String> userType);  

如何通过 postgresql 查询在字符串列表中搜索枚举?


推荐阅读