SqlExceptionHelper - 在此 ResultSet 中找不到列名 ...

SqlExceptionHelper - The column name ... was not found in this ResultSet

这是查询:

UPDATE einvoice_message AS e1 
  SET message = null 
FROM (
  SELECT * 
  FROM einvoice_message 
  where created < :created 
  ORDER BY :created LIMIT :limit 
  FOR UPDATE SKIP LOCKED
) AS e2 
WHERE e1.einvoice_message_id = e2.einvoice_message_id 
RETURNING e1.einvoice_message_id

我正在 SqlExceptionHelper - The column name created was not found in this ResultSet. 不明白为什么和在哪里?需要帮助。

Java代码:

@Query(value = "UPDATE einvoice_message AS e1 SET message = null FROM (SELECT * FROM einvoice_message 
where created < :created ORDER BY :created LIMIT :limit FOR UPDATE SKIP LOCKED) AS e2 WHERE 
e1.einvoice_message_id = e2.einvoice_message_id RETURNING e1.einvoice_message_id", nativeQuery = true)
List<EinvoiceMessage> deleteEinvoiceMessageContent(@Param("created") OffsetDateTime created, 
@Param("limit") int limit);

这是我的 table ddl:

create table einvoice_message
(
    einvoice_message_id bigserial not null
        constraint einvoice_message_pk
            primary key,
    message bytea not null,
    created timestamp default now() not null
);

:created 变量更改为列 created 未能解决问题。

问题在于此的 return 值。 RETURNING e1.einvoice_message_id 将 return 一个数字,而不是我提到的列表。正确答案是:

@Query(value = "UPDATE einvoice_message AS e1 SET message = null FROM (SELECT * FROM einvoice_message 
where created < :created ORDER BY :created LIMIT :limit FOR UPDATE SKIP LOCKED) AS e2 WHERE 
e1.einvoice_message_id = e2.einvoice_message_id RETURNING e1.einvoice_message_id", nativeQuery = true)
int deleteEinvoiceMessageContent(@Param("created") OffsetDateTime created, 
@Param("limit") int limit);