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
NUMBER(2)ByteCovers -99 to 99.
NUMBER(3)ShortCovers -999 to 999; Byte cannot cover the full column range.
NUMBER(5)IntegerCovers -99999 to 99999; Short cannot cover the full column range.
NUMBER(10)LongCovers 10-digit decimal integers; Integer cannot cover the full column range.
NUMBER(19)BigIntegerCovers 19-digit decimal integers; Long cannot cover the full column range.
NUMBER(p, 0)BigIntegerGeneral integral mapping; choose smaller integer types when the range permits, or BigDecimal for a common decimal model.
NUMBER(p, s)BigDecimalUse for fractional values or a common decimal representation.
NUMBER(1)BooleanOnly for application-defined 0/1 flags; use Byte for ordinary one-digit integers.
BINARY_FLOATFloatApproximate values; not for amounts requiring exact decimal arithmetic.
BINARY_DOUBLEDoubleApproximate values; not for amounts requiring exact decimal arithmetic.
CHAR(1)StringText content; the column definition constrains length.
VARCHAR2(255)StringText content; the column definition constrains length.
NVARCHAR2(255)StringText content; the column definition constrains length.
RAW(1000)byte[]Binary content without character encoding conversion.
BLOBbyte[]Binary content without character encoding conversion.
DATEjava.sql.TimestampPreserves date and time, subject to column precision.
TIMESTAMPjava.sql.TimestampPreserves date and time, subject to column precision.
VARCHAR2(2000)Map / List / BeanWhen storing JSON text, see JSON Field Mapping.
CLOBMap / List / BeanWhen storing JSON text, see JSON Field Mapping.

Example: Declare Entity Properties for Table Fields

These are field declarations inside an entity, with column names set by @Column. Handlers are selected from property types and mapping configuration; these ordinary numeric properties do not require explicit JDBC types.

import java.math.BigDecimal;
import net.hasor.dbvisitor.mapping.Column;

// NUMBER(3)
@Column("quantity")
private Short quantity;

// NUMBER(5)
@Column("sort_no")
private Integer sortNo;

// NUMBER(10, 2)
@Column("amount")
private BigDecimal amount;

Basic Types: Empty Strings

An empty VARCHAR2 string is read as null. For binding examples and how to preserve the distinction, see Empty String Parameters.

Binary Types: Empty BLOBs

Regular byte[] values can store binary data, but Oracle JDBC's setBytes binds new byte[0] as NULL.

To store a zero-length BLOB, create it with Connection.createBlob() and bind it with PreparedStatement.setBlob(). Reading an empty BLOB returns a zero-length byte[]; reading NULL returns null.

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.