我想使用Hibernate current_timestamp()根据数据库时间为列编写时间戳。我希望使用数据库时间,而不是使用数据库的服务系统的系统时间。我使用数据库时间进行两个查询,锁和解锁。UPDATE MyEntity e SET e.lock = current_timestamp() WHERE e.id = :idUPDATE MyEntity e SET e.lock = (current_timestamp() - "30 seconds") WHERE e.id = :id
我最后的方法是对PostgreSQL使用一个本机查询,如下所示
我需要更新一列,并根据旧值,更新第二列。 1 | 1* | 1 | 1 | 5* | 1 | 1 |它正确地执行第一行(将b1更新为5),但不执行第二行,即设置mysql手册指出:
The second assignment in the following statement sets col2 to the cu