Skip to content

Data Type Mapping

Mirro Mutth edited this page Feb 21, 2024 · 2 revisions

INT UNSIGNED

Default: Long

Others: BigInteger, Float, Double, BigDecimal

INT SIGNED

Default: Integer

Others: Long, BigInteger, Float, Double, BigDecimal

TINYINT UNSIGNED

Default: Short

Others: Integer, Long, BigInteger, Float, Double, BigDecimal

Specials: Boolean if it is TINYINT(1) UNSIGNED

TINYINT SIGNED

Default: Byte

Others: Short, Integer, Long, BigInteger, Float, Double, BigDecimal

Specials: Boolean if it is TINYINT(1) SIGNED

BOOLEAN

It is an alias of TINYINT(1) SIGNED in MySQL.

SMALLINT UNSIGNED

Default: Integer

Others: Long, BigInteger, Float, Double, BigDecimal

SMALLINT SIGNED

Default: Short

Others: Integer, Long, BigInteger, Float, Double, BigDecimal

MEDIUMINT SIGNED/UNSIGNED

Default: Integer

Others: Long, BigInteger, Float, Double, BigDecimal

BIGINT UNSIGNED

Default: BigInteger

Others: Long, Float, Double, BigDecimal

BIGINT SIGNED

Default: Long

Others: BigInteger, Float, Double, BigDecimal

FLOAT SIGNED/UNSIGNED

Default: Float

Others: Double, BigDecimal

DOUBLE SIGNED/UNSIGNED

Default: Double

Others: Float, BigDecimal

DECIMAL SIGNED/UNSIGNED

Default: BigDecimal

Others: Float, Double

BIT

Default: ByteBuffer

Others: BitSet, byte[]

Specials: Boolean if it is BIT(1)

DATETIME

Default: LocalDateTime

Others: ZonedDateTime, OffsetDateTime, Instant

TIMESTAMP

Default: ZonedDateTime

Others: LocalDateTime, OffsetDateTime, Instant

DATE

Default: LocalDate

TIME

Default: LocalTime

Others: Duration, OffsetTime

YEAR

Default: Short

Others: Integer, Long, BigInteger, Year, Float, Double, BigDecimal

VARCHAR / NVARCHAR / CHAR / NCHAR

Default: String

VARBINARY

Default: ByteBuffer

Others: byte[]

ENUM

Default: String

Others: enum class

SET

Default: String[]

Others: String

Specials: Set<T>, require getting it with a ParameterizedType, T should be String or an enum class

BLOB / LONGBLOB / MEDIUMBLOB / TINYBLOB

Default: ByteBuffer

Others: Blob, byte[]

TEXT / LONGTEXT / MEDIUMTEXT / TINYTEXT / JSON

Default: String

Others: Clob

The JSON in some distributions is an alias for TEXT.

GEOMETRY

Default: byte[]

Others: Blob