-1
Query quer = sess.createQuery("update materialrate  set materialId=:MaterialId, subWorkId=:SubWorkId,unitId=:UnitId ,rate=:Rate, lastUpdatedUserId=:LastUpdatedUserId  where materialRateId=:MaterialRateId");
 quer.setInteger("materialId", n.getMaterialId());
        quer.setInteger("subWorkId", n.getSubWorkId());
        quer.setInteger("unitId", n.getUnitId());
        quer.setInteger("rate",n.getRate());
       // quer.setDate("lastUpdatedDate", current_timestamp());//lastUpdateDate=:current_timestamp() ,
        quer.setInteger("lastUpdatedUserId", n.getLastUpdatedUserId());
        quer.executeUpdate();
4

1 回答 1

1

由于您使用的是命名参数,因此在设置这些参数的值时需要使用相同的名称。用以下行替换您的代码:

Query quer = sess.createQuery("update materialrate  set materialId=:MaterialId, subWorkId=:SubWorkId,unitId=:UnitId ,rate=:Rate, lastUpdatedUserId=:LastUpdatedUserId  where materialRateId=:MaterialRateId");
 quer.setInteger("MaterialId", n.getMaterialId());
        quer.setInteger("SubWorkId", n.getSubWorkId());
        quer.setInteger("UnitId ", n.getUnitId());
        quer.setInteger("Rate",n.getRate());
       // quer.setDate("lastUpdatedDate", current_timestamp());//lastUpdateDate=:current_timestamp() ,
        quer.setInteger("LastUpdatedUserId ", n.getLastUpdatedUserId());
        quer.executeUpdate();
于 2013-03-27T17:28:46.617 回答