English | 简体中文

api-docs / org.ktorm.schema / SqlType

SqlType

abstract class SqlType<T : Any> (source code)

Abstraction of SQL data types.

Based on JDBC, SqlType and its subclasses encapsulate the common operations of obtaining data from a ResultSet
and setting parameters to a PreparedStatement.

Constructors

NameSummary

<init>

SqlType(typeCode: Int, typeName: String)

Abstraction of SQL data types.

Properties

NameSummary

typeCode

val typeCode: Int

a constant value defined in java.sql.Types to identify JDBC types.

typeName

val typeName: String

the name of the type in specific databases, such as int, bigint, varchar, etc.

Functions

NameSummary

doGetResult

abstract fun doGetResult(rs: ResultSet, index: Int): T?

Obtain a result from a given ResultSet by index, the result may be null.

doSetParameter

abstract fun doSetParameter(
    ps: PreparedStatement,
    index: Int,
    parameter: T
): Unit

Set the parameter to a given PreparedStatement, the parameter can’t be null.

equals

open fun equals(other: Any?): Boolean

Indicates whether some other object is “equal to” this SQL type.
Two SQL types are equal if they have the same type codes and names.

getResult

open fun getResult(rs: ResultSet, index: Int): T?

Obtain a result from a given ResultSet by index.

open fun getResult(rs: ResultSet, columnLabel: String): T?

Obtain a result from a given ResultSet by columnLabel.

hashCode

open fun hashCode(): Int

Return a hash code value for this SQL type.

setParameter

open fun setParameter(
    ps: PreparedStatement,
    index: Int,
    parameter: T?
): Unit

Set the nullable parameter to a given PreparedStatement.

transform

open fun <R : Any> transform(
    fromUnderlyingValue: (T) -> R,
    toUnderlyingValue: (R) -> T
): SqlType<R>

Transform this SqlType to another. The returned SqlType has the same typeCode and typeName as the
underlying one, and performs the specific transformations on column values.

Companion Object Functions

NameSummary

of

fun <T : Any> of(): SqlType<T>?

Return the corresponding ktorm core built-in SqlType for kotlin type T.

Extension Functions

NameSummary

eq

infix fun <T : Any> T.eq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Equal operator, translated to = in SQL.

neq

infix fun <T : Any> T.neq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Not-equal operator, translated to <> in SQL.

notEq

infix fun <T : Any> T.notEq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Not-equal operator, translated to <> in SQL.

Inheritors

NameSummary

BlobSqlType

object BlobSqlType : SqlType<ByteArray>

SqlType implementation represents blob SQL type.

BooleanSqlType

object BooleanSqlType : SqlType<Boolean>

SqlType implementation represents boolean SQL type.

BytesSqlType

object BytesSqlType : SqlType<ByteArray>

SqlType implementation represents bytes SQL type.

CubeSqlType

object CubeSqlType : SqlType<Cube>

Represents a Cube by storing 2 n-dimensional points
Part of PostgreSQL cube SQL extension.
https://www.postgresql.org/docs/9.5/cube.html

DateSqlType

object DateSqlType : SqlType<Date>

SqlType implementation represents date SQL type.

DateTimeOffsetSqlType

object DateTimeOffsetSqlType : SqlType<OffsetDateTime>

SqlType implementation represents SQL Server datetimeoffset SQL type.

DecimalSqlType

object DecimalSqlType : SqlType<BigDecimal>

SqlType implementation represents decimal SQL type.

DoubleSqlType

object DoubleSqlType : SqlType<Double>

SqlType implementation represents double SQL type.

EarthSqlType

object EarthSqlType : SqlType<Earth>

Cube-based earth abstraction, using 3 coordinates representing the x, y, and z distance from the center of the Earth.
Part of PostgreSQL earthdistance SQL extension.

EnumSqlType

class EnumSqlType<C : Enum<C>> : SqlType<C>

SqlType implementation that saves enums as strings.

FloatSqlType

object FloatSqlType : SqlType<Float>

SqlType implementation represents float SQL type.

HStoreSqlType

object HStoreSqlType : SqlType<HStore>

SqlType implementation represents PostgreSQL hstore type.

InstantSqlType

object InstantSqlType : SqlType<Instant>

SqlType implementation represents timestamp SQL type.

IntSqlType

object IntSqlType : SqlType<Int>

SqlType implementation represents int SQL type.

JsonSqlType

class JsonSqlType<T : Any> : SqlType<T>

SqlType implementation that provides JSON data type support via Jackson framework.

LocalDateSqlType

object LocalDateSqlType : SqlType<LocalDate>

SqlType implementation represents date SQL type.

LocalDateTimeSqlType

object LocalDateTimeSqlType : SqlType<LocalDateTime>

SqlType implementation represents datetime SQL type.

LocalTimeSqlType

object LocalTimeSqlType : SqlType<LocalTime>

SqlType implementation represents time SQL type.

LongSqlType

object LongSqlType : SqlType<Long>

SqlType implementation represents long SQL type.

MonthDaySqlType

object MonthDaySqlType : SqlType<MonthDay>

SqlType implementation used to save MonthDay instances, formatting them to strings with pattern MM-dd.

ShortSqlType

object ShortSqlType : SqlType<Short>

SqlType implementation represents smallint SQL type.

TextArraySqlType

object TextArraySqlType : SqlType<TextArray>

SqlType implementation represents PostgreSQL text[] type.

TextSqlType

object TextSqlType : SqlType<String>

SqlType implementation represents text SQL type.

TimeSqlType

object TimeSqlType : SqlType<Time>

SqlType implementation represents time SQL type.

TimestampSqlType

object TimestampSqlType : SqlType<Timestamp>

SqlType implementation represents timestamp SQL type.

UuidSqlType

object UuidSqlType : SqlType<UUID>

SqlType implementation represents uuid SQL type.

VarcharSqlType

object VarcharSqlType : SqlType<String>

SqlType implementation represents varchar SQL type.

YearMonthSqlType

object YearMonthSqlType : SqlType<YearMonth>

SqlType implementation used to save YearMonth instances, formatting them to strings with pattern yyyy-MM.

YearSqlType

object YearSqlType : SqlType<Year>

SqlType implementation used to save Year instances as integers.