Show TOC Start of Content Area

Background documentation Type Mapping  Locate the document in its SAP Library structure

It is possible to map a persistent field to a database column when the Java type of the field is compatible with the JDBC type of the column. This ensures that no data is lost when reading a persistent field on all supported platforms.

The following table lists the compatible JDBC types for the basic Java types. For each Java type there is a default JDBC mapping, which should be used whenever possible.

Java and JDBC Type Mapping

Java Type

Acceptable JDBC Type

Default JDBC Type

boolean, java.lang.Boolean

SMALLINT, BIT, INTEGER, BIGINT

SMALLINT

byte, java.lang.Byte

SMALLINT, DECIMAL, NUMERIC

SMALLINT

short, java.lang.Short

SMALLINT, DECIMAL, NUMERIC

SMALLINT

int, java.lang.Integer

INTEGER, DECIMAL, NUMERIC

INTEGER

long, java.lang.Long

BIGINT, DECIMAL, NUMERIC

BIGINT

float, java.lang.Float

REAL, FLOAT, DOUBLE

REAL

double, java.lang.Double

DOUBLE

DOUBLE

char, java.lang.Character

INTEGER, CHAR , DECIMAL, NUMERIC

INTEGER

java.lang.String

VARCHAR, LONGVARCHAR, CLOB, CHAR

VARCHAR, LONGVARCHAR, CLOB

Note

The default JDBC type for java.lang.String depends on the maximum length of string to be stored. For a maximum length of 127, the default is VARCHAR. For a maximum length of 1333, the default is LONGVARCHAR. If the maximum length is bigger than 1333, the default is CLOB.

java.util.Date

TIMESTAMP, BIGINT

TIMESTAMP

java.sql.Date

DATE

DATE

java.sql.Time

TIME

TIME

java.sql.Timestamp

TIMESTAMP

TIMESTAMP

java.lang.Local

VARCHAR, CHAR, LONGVARCHAR

VARCHAR

java.lang.BigInteger

DECIMAL, NUMERIC

DECIMAL

java.lang.BigDecimal

DECIMAL, NUMERIC

DECIMAL

 

The following table contains the permitted JDBC types for columns with special function – for example, the discriminator column.

JDBC Types for Columns with Special Function

Column

Acceptable JDBC Type

Default JDBC Type

Discriminator

VARCHAR, CHAR, LONGVARCHAR

VARCHAR

Count

INTEGER

INTEGER

Reference

VARCHAR, CHAR, LONGVARCHAR, VARBINARY, LONGVARBINARY

VARCHAR

Serialized Data

BLOB

BLOB

 

 

 

 

End of Content Area