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

Java 如何通过postgresql查询在字符串列表中搜索枚举?,java,postgresql,enums,sql-in,Java,Postgresql,Enums,Sql In,考虑一个SQL语句: select * from table where status in <statuses> handle.createQuery("select * from table where status in <statuses>") .bindList("statuses", statuses) .map(Mapper.instance)

考虑一个SQL语句:

select * from table where status in <statuses>
handle.createQuery("select * from table where status in <statuses>")
                    .bindList("statuses", statuses)
                    .map(Mapper.instance)
                    .list());
在Java中,我有一个字符串表示的枚举列表:

List<String> list = new ArrayList<>();
list.add("enum1");
list.add("enum2");
我尝试用CAST(enum1作为statusType)或enum1::statusType包装每个列表项,但没有成功


非常感谢您的帮助。

您可以将枚举转换为文本

handle.createQuery("select * from table where status::text in <statuses>")
                .bindList("statuses", statuses)
                .map(Mapper.instance)
                .list());
handle.createQuery(“从status::text所在的表中选择*)
.bindList(“状态”,状态)
.map(Mapper.instance)
.list());

您是否尝试过此
select*from table where status::text in
org.jdbi.v3.core.statement.UnableToExecuteStatementException: org.postgresql.util.PSQLException: ERROR: operator does not exist: status = character varying
  Hint: No operator matches the given name and argument types. You might need to add explicit type casts.

handle.createQuery("select * from table where status::text in <statuses>")
                .bindList("statuses", statuses)
                .map(Mapper.instance)
                .list());