$1 处或附近的语法错误以及一些异常 sql 语法异常

syntax error at or near $1 and also some exception sql grammar exception

我在 1 美元或接近 1 美元时遇到语法错误,还有一些异常 sql 语法异常

"select t1.* from ( select * from employee_additional_attributes  where stwid in :stwIdList )"
            + "as t1 join ( select stwid, max(employee_additional_attribute_id) as employee_additional_attribute_id from employee_additional_attributes"
            + "where stwid in :stwIdList and mis_attribute_id in (:attributeId) and start_time <= date(:date) group by stwid )"
            + "as t2 using ( stwid, employee_additional_attribute_id" )

PostgreSQL 在参数化查询中使用 $<n> 语法作为占位符(例如底层连接中的准备语句)。

您的第一个 (</code>) 参数存在语法错误:<br> (当然还有一些白色-space 语法错误,@Jens 提到过)</p> <pre><code>where stwid in :stwIdList

IN 的正确语法是 <expression> IN (<expression>, ...)。您不能使用单个参数绑定多个值(使用 JDBC)。如果可以绑定数组,则可以使用 <expression> = ANY (<array-expression>) 语法。

对于休眠,请参阅此 related question(注意查询参数周围的括号)。