简体   繁体   English

jOOQ使用Where子句更新查询

[英]jOOQ Update query with Where clause

How to add Where clause with Update query in jOOQ? 如何在jOOQ中使用Update查询添加Where子句?

AccountPaymentRecord aacntPaymentRec = new AccountPaymentRecord();
aacntPaymentRec.setReceiptNumber(PaymentNumberFrom);
aacntPaymentRec.setPaymentComment(ReasonFrom);
transfeeTransfer.update(aacntPaymentRec);

I have to add Where clause as well. 我还必须添加Where子句。 How to do it? 怎么做?

Since you're operating on UpdatableRecord , you might want to follow what's documented here, in the manual . 由于您在UpdatableRecord操作,因此您可能需要按照手册中此处记录的内容进行操作 Another place to look for information are the jOOQ manual's sections about the UPDATE statement . 查找信息的另一个地方是jOOQ手册中有关UPDATE语句的部分

A possible solution for you: 一个可能的解决方案:

With the code from which you have started, one possible solution would be to use DSLContext.executeUpdate(R, Condition) : 使用您从中开始的代码,一种可能的解决方案是使用DSLContext.executeUpdate(R, Condition)

AccountPaymentRecord aacntPaymentRec = new AccountPaymentRecord();
aacntPaymentRec.setReceiptNumber(PaymentNumberFrom);
aacntPaymentRec.setPaymentComment(ReasonFrom);
DSL.using(configuration)
   .executeUpdate(aacntPaymentRec, ACCOUNT_PAYMENT.ID.eq(123));

Thanks @Lukas in my case i have to use like this 谢谢@Lukas在我的情况下,我必须像这样使用

AccountPaymentRecord aacntPaymentRec = transfeeTransfer.fetchOne(AccountPayment.ACCOUNT_PAYMENT,
                AccountPayment.ACCOUNT_PAYMENT.PAYMENT_NUMBER.eq(PaymentNumberTo));
aacntPaymentRec.setReceiptNumber(PaymentNumberFrom);
aacntPaymentRec.setPaymentComment(ReasonFrom);
aacntPaymentRec.update();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM