首页 > 解决方案 > Kotlin 暴露框架

问题描述

我是 kotlin 暴露框架的新手。我想要达到的目的是按 CLOB 列的长度对一些结果进行排序。

表达式如下所示:

ProductReviewTable.join(
                otherTable = ReviewTable,
                joinType = JoinType.INNER,
                additionalConstraint = {
                    ProductReviewTable.review eq ReviewTable.id
                }
        ).join(
                otherTable = UserProductRatingTable,
                joinType = JoinType.LEFT,
                additionalConstraint = {
                    (UserProductRatingTable.productId eq ProductReviewTable.productId) and
                            (UserProductRatingTable.userId eq ReviewTable.userId)
                }
        )
          .select {
          (ProductReviewTable.productId eq productId) and ACCEPTED_REVIEWS_EXPRESSION
        }
                .limit(count, offset = offset)
          .orderBy(
            Pair(ReviewTable.priority, SortOrder.DESC),
            Pair(ReviewTable.valuable, SortOrder.DESC),
            Pair(ReviewTable.useful, SortOrder.DESC),
            Pair(ReviewTable.content, SortOrder.DESC),  // here i want to order by content length
            Pair(ReviewTable.createdDate, SortOrder.DESC)
          )
                .mapNotNull { it.toReviewDto() }
    }

是否有任何功能可以让我将 CLOB 'content' 列转换为长度,然后按它排序?我使用 oracle 作为数据库,您不能在 order by 子句中使用 CLOB 列类型。

在 oracle 中可以这样做:

SELECT length(CONTENT) FROM REVIEW r 
ORDER BY 1 DESC NULLS LAST

但我不知道如何在 kotlin 暴露的框架中表达

标签: oraclekotlinormkotlin-exposed

解决方案


推荐阅读