Skip to main content

Type Support

The table recommends Java property types for common columns. Use wrapper types for nullable fields. See Java/JDBC types and enum mapping.

Type Mappings

Database field typeJava typeDescription
TINYINTByteByte is recommended for signed TINYINT; UNSIGNED needs a wider type.
SMALLINTShortCovers the range of this signed integer type.
INTIntegerCovers the range of this signed integer type.
BIGINTLongCovers the range of this signed integer type.
FLOATFloatApproximate values; not for amounts requiring exact decimal arithmetic.
DOUBLEDoubleApproximate values; not for amounts requiring exact decimal arithmetic.
DECIMAL(10, 2)BigDecimalRetains decimal values; writes are constrained by column precision and scale.
DECIMAL(20, 0)BigInteger / BigDecimalUse BigInteger for integral business values, or BigDecimal for a common decimal model.
BIT(1)BooleanUse Boolean semantics, not a general integer property.
BOOLEANBooleanMySQL treats it as a synonym for TINYINT(1); use it for 0/1 Boolean semantics.
CHAR(1)StringText content; the column definition constrains length.
VARCHAR(255)StringText content; the column definition constrains length.
VARBINARY(1000)byte[]Binary content without character encoding conversion.
LONGBLOBbyte[]Binary content without character encoding conversion.
DATEjava.sql.DateDate only; not for preserving a complete timestamp.
TIMEjava.sql.TimeTime only; text storage requires a parseable time format.
DATETIME(3)java.sql.TimestampPreserves date and time, subject to column precision.
VARCHAR(2000)Map / List / BeanWhen storing JSON text, see JSON Field Mapping.
JSONMap / List / BeanSee JSON Field Mapping for entity-property configuration.

Read TINYINT(1) as a Number

  • Flags: use Boolean for true/false.
  • Numeric status codes: use Byte or Integer and set tinyInt1isBit=false in the connection URL:
jdbc:mysql://localhost:3306/appdb?tinyInt1isBit=false

For example, when a signed TINYINT(1) stores 2, the default getObject() read returns true; with this setting, it returns the number 2. Explicit integer reads are unaffected.

Array Types

NULL can be read as a Java null, but non-null arrays cannot be bound, read, or updated through the generic JDBC ARRAY mapping. For example, binding Integer[] with Types.ARRAY is not supported.

To store a list in one field, use a suitable text or JSON column and JSON field mapping. Do not configure that column as JDBC ARRAY. This is separate from expanding a list into an IN condition.