首页 > 解决方案 > 在 where 子句中使用 uuid 列更新表的列值时出现问题

问题描述

当我尝试使用 where 子句中的 uuid 列更新列值时,出现错误。

Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

我正在使用带有本机查询的 spring boot。这是本机查询:

 @Query(value = "UPDATE employee " +
            "SET status = :status  where employeeId = :employeeId", nativeQuery = true)
    @Transactional
    @Modifying
    void updateROGS(@Param("status") String status, @Param("employeeId") UUID employeeId);

标签: sqlpostgresql

解决方案


是否值得将employeeId 转换为键入文本以便于比较,然后将您的参数作为字符串发送?

就像是;

@Query(value = "UPDATE employee " +
            "SET status = :status  where employeeId::text = :employeeId", nativeQuery = true)
    @Transactional
    @Modifying
    void updateROGS(@Param("status") String status, @Param("employeeId") String employeeId);

推荐阅读