All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tcds.orm.column.nullable.NullableJsonColumn.kt Maven / Gradle / Ivy

Go to download

Kotlin Simple ORM is a simple but powerful database orm for kotlin applications

There is a newer version: 0.3.14
Show newest version
package io.tcds.orm.column.nullable

import io.tcds.orm.Column
import io.tcds.orm.column.JsonColumn
import java.sql.PreparedStatement
import java.sql.Types

class NullableJsonColumn(name: String, value: (Entity) -> T?) : Column(name, value) {
    override fun columnType(): String = "JSON NULL"

    override fun bind(stmt: PreparedStatement, index: Int, value: T?) {
        when (value) {
            null -> stmt.setNull(index, Types.VARCHAR)
            else -> stmt.setString(index, JsonColumn.mapper.writeValueAsString(value))
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy