这是我的问题..
SelectQuery<Record> selectQuery = transRefundFee.selectQuery();
selectQuery.addSelect(AccountBill.ACCOUNT_BILL.BILL_NUMBER,AccountBill.ACCOUNT_BILL.BILL_AMOUNT,AccountBill.ACCOUNT_BILL.TOTAL_PAID );
selectQuery.addFrom(AccountBill.ACCOUNT_BILL);
selectQuery.addConditions(AccountBill.ACCOUNT_BILL.FOLDER_RSN.eq(argFolderRSN));
我必须使用 Case 语句添加 orderby 我们该怎么做我检查过 Here但在我的情况下,我像这样添加的任何其他方式都不起作用
selectQuery.addOrderBy( DSL.decode().when(AccountBill.ACCOUNT_BILL.BILL_AMOUNT.le(new BigDecimal(0)),AccountBill.ACCOUNT_BILL.BILL_AMOUNT).then(AccountBill.ACCOUNT_BILL.BILL_AMOUNT) .otherwise(AccountBill.ACCOUNT_BILL.BILL_NUMBER));
但它说The method then(TableField<AccountBillRecord,BigDecimal>) is undefined for the type CaseConditionStep<BigDecimal>
与下面的代码相同
selectQueryFee.addOrderBy(DSL.decode().when(AccountBill.ACCOUNT_BILL.BILL_AMOUNT.le(new BigDecimal(0))
.then(AccountBill.ACCOUNT_BILL.BILL_AMOUNT)
.otherwise(AccountBill.ACCOUNT_BILL.BILL_NUMBER)));
The method then(TableField) is undefined for the type Condition
最佳答案
从 jOOQ 3.2 开始,CASE
表达式支持未实现 when()
... then()
结构,即有没有 then()
关键字。相反,写:
DSL.decode()
.when(AccountBill.ACCOUNT_BILL.BILL_AMOUNT.le(new BigDecimal(0)),
AccountBill.ACCOUNT_BILL.BILL_AMOUNT)
.otherwise(AccountBill.ACCOUNT_BILL.BILL_NUMBER)
jOOQ 路线图上有一个待处理的功能请求来纠正此问题:#615
关于java - JOOQ Orderby 与案例陈述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19680649/