Skip to content
Discussion options

You must be logged in to vote
data class MoneySum(
    val expr: Expression<Money>,
    val distinct: Boolean = false,
) : Expression<Long>

class JpqlMoneySumSerializer : JpqlSerializer<MoneySum> {
    override fun handledType(): KClass<MoneySum> = MoneySum::class

    override fun serialize(part: MoneySum, writer: JpqlWriter, context: RenderContext) {
        val delegate = context.getValue(JpqlRenderSerializer)

        writer.write("SUM")

        writer.writeParentheses {
            if (part.distinct) {
                writer.write("DISTINCT")
                writer.write(" ")
            }

            delegate.serialize(part.expr, writer, context)
        }
    }
}

class MyJpql : Jpql() {
    companion object

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@shouwn
Comment options

Answer selected by WoongE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants