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
SMALLINTShortCovers the range of this signed integer type.
INTEGERIntegerCovers the range of this signed integer type.
BIGINTLongCovers the range of this signed integer type.
REALFloatApproximate values; not for amounts requiring exact decimal arithmetic.
DOUBLE PRECISIONDoubleApproximate values; not for amounts requiring exact decimal arithmetic.
DECIMAL(10, 2)BigDecimalRetains decimal values; writes are constrained by column precision and scale.
NUMERIC(20)BigInteger / BigDecimalUse BigInteger for integral business values, or BigDecimal for a common decimal model.
BIT(1)BooleanSuitable only when a one-bit value is used as an application flag. PostgreSQL BIT is a bit-string type, not a synonym for BOOLEAN.
BOOLEANBooleanUse Boolean semantics, not a general integer property.
CHAR(1)StringText content; the column definition constrains length.
VARCHAR(255)StringText content; the column definition constrains length.
BYTEAbyte[]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.
TIMESTAMPjava.sql.TimestampPreserves date and time, subject to column precision.
VARCHAR(2000)Map / List / BeanWhen storing JSON text, see JSON Field Mapping.
JSONBMap / List / BeanSee JSON Field Mapping for entity-property configuration.
INTEGER[]Integer[]Array elements match the database element type; configure the handler explicitly when needed.
VARCHAR[]String[]Array elements match the database element type; configure the handler explicitly when needed.
REAL[]Float[]Array elements match the database element type; configure the handler explicitly when needed.
vector(n)List<Float>See Vector Operations for mapping; the vector length must match the column dimension.

Array Types​

CREATE TABLE array_example (id INTEGER PRIMARY KEY, values_col INTEGER[]);
import java.sql.Types;
import net.hasor.dbvisitor.types.SqlArg;
import net.hasor.dbvisitor.types.handler.array.ArrayTypeHandler;

Integer[] values = { 10, 20, 30 };
jdbcTemplate.executeUpdate("INSERT INTO array_example (id, values_col) VALUES (?, ?)",
new Object[] { 1, new SqlArg(values, Types.ARRAY, new ArrayTypeHandler()) });
Integer[] loaded = jdbcTemplate.queryForObject(
"SELECT values_col FROM array_example WHERE id = ?",
new Object[] { 1 }, Integer[].class);