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 type | Java type | Description |
|---|---|---|
| TINYINT | Byte | Byte is recommended for signed TINYINT; UNSIGNED needs a wider type. |
| SMALLINT | Short | Covers the range of this signed integer type. |
| INT | Integer | Covers the range of this signed integer type. |
| BIGINT | Long | Covers the range of this signed integer type. |
| FLOAT | Float | Approximate values; not for amounts requiring exact decimal arithmetic. |
| DOUBLE | Double | Approximate values; not for amounts requiring exact decimal arithmetic. |
| DECIMAL(10, 2) | BigDecimal | Retains decimal values; writes are constrained by column precision and scale. |
| DECIMAL(20, 0) | BigInteger / BigDecimal | Use BigInteger for integral business values, or BigDecimal for a common decimal model. |
| BIT(1) | Boolean | Use Boolean semantics, not a general integer property. |
| BOOLEAN | Boolean | MySQL treats it as a synonym for TINYINT(1); use it for 0/1 Boolean semantics. |
| CHAR(1) | String | Text content; the column definition constrains length. |
| VARCHAR(255) | String | Text content; the column definition constrains length. |
| VARBINARY(1000) | byte[] | Binary content without character encoding conversion. |
| LONGBLOB | byte[] | Binary content without character encoding conversion. |
| DATE | java.sql.Date | Date only; not for preserving a complete timestamp. |
| TIME | java.sql.Time | Time only; text storage requires a parseable time format. |
| DATETIME(3) | java.sql.Timestamp | Preserves date and time, subject to column precision. |
| VARCHAR(2000) | Map / List / Bean | When storing JSON text, see JSON Field Mapping. |
| JSON | Map / List / Bean | See JSON Field Mapping for entity-property configuration. |
Read TINYINT(1) as a Number
- Flags: use
Booleanfortrue/false. - Numeric status codes: use
ByteorIntegerand settinyInt1isBit=falsein 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.