java - JOOQ Orderby 与案例陈述

标签 java sql jooq

这是我的问题..

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/

相关文章:

java - 如何创建集合的数组?

java - 将Windows编译的war部署到Linux上的Weblogic

mysql - 无法让 MySQL 在 INSERT 语句之前接受 NOT EXISTS

java - 带嵌套列表的 jOOQ 查询

java - 使用 JOOQ 的 Spring 启动收到一条消息 "required a bean of type ' org.jooq.DSLContext' 无法找到”

java - 必须学习Java类!

java - 插入到实现泛型的二叉搜索树中

mysql - mysql 中 SELECT 中的 IF 语句

java servlet删除不重定向

java - Jooq 3.9 不将 MySQL 列链接到枚举