小编典典

在一个休眠查询中更新几列?

hibernate

我有以下HQL:

String hql = "UPDATE Buchung as b " +
             "set STORNO = :Storno " +
             "where ID = :BuchungID";

是否可以在HQL中更新多于一列的数据?例如:

String hql = "UPDATE Buchung as b " +
              "set STORNO = :Storno " +
              "set NAME = :Name " +
               ......  
              "where ID = :BuchungID";

我知道如何在MSSQL中做到这一点,但我不知道如何在Hibernate中做到这一点。


阅读 302

收藏
2020-06-20

共1个答案

小编典典

在这种情况下,HQL与SQL相同。只需使用逗号分隔各列:

String hql = "UPDATE Buchung as b set " +
          "STORNO = :Storno," +
          "NAME = :Name " +
           ......  
          "where ID = :BuchungID";
2020-06-20