sql - 在 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);
解决方案
是否值得将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);
推荐阅读
- mysql - 从 2 个不同的表中选择
- reactjs - 如何自动填写反应材料表
- laravel - Laravel - 如何处理 $fillable 插入和更新中的非必需/可选字段
- batch-file - 使用命令提示符将文件名及其内容复制到新文件中
- firebase - 如何根据文档ID更新和删除列表中的数据-flutter,firebase 2021
- maven - 使用 GraalVM、Maven、GluonFX 插件的本机映像 - 资源包 com.sun.glass.ui.win 的问题
- javascript - 应用脚本中的字符串搜索不起作用
- rust - 将字符串切片的迭代器转换为向量
- python - 如何更改 pmt 对中值的精度
- c++ - 在 C++ 中的屏幕上居中文本坐标