如何在jOOQ中添加Where
子句和更新查询?
AccountPaymentRecord aacntPaymentRec = new AccountPaymentRecord();
aacntPaymentRec.setReceiptNumber(PaymentNumberFrom);
aacntPaymentRec.setPaymentComment(ReasonFrom);
transfeeTransfer.update(aacntPaymentRec);
我还必须添加Where
子句。怎么做?
答案 0 :(得分:1)
由于您在UpdatableRecord
上操作,因此您可能需要关注what's documented here, in the manual。另一个查找信息的地方是jOOQ manual's sections about the UPDATE
statement。
使用您已启动的代码,一种可能的解决方案是使用DSLContext.executeUpdate(R, Condition)
:
AccountPaymentRecord aacntPaymentRec = new AccountPaymentRecord();
aacntPaymentRec.setReceiptNumber(PaymentNumberFrom);
aacntPaymentRec.setPaymentComment(ReasonFrom);
DSL.using(configuration)
.executeUpdate(aacntPaymentRec, ACCOUNT_PAYMENT.ID.eq(123));
答案 1 :(得分:1)
在我的情况下感谢@Lukas,我必须像这样使用
AccountPaymentRecord aacntPaymentRec = transfeeTransfer.fetchOne(AccountPayment.ACCOUNT_PAYMENT,
AccountPayment.ACCOUNT_PAYMENT.PAYMENT_NUMBER.eq(PaymentNumberTo));
aacntPaymentRec.setReceiptNumber(PaymentNumberFrom);
aacntPaymentRec.setPaymentComment(ReasonFrom);
aacntPaymentRec.update();