2.4.2 Mapping the CMP field and database

This section describes the mapping of the CMP field and database. The mapping will differ for each type of database.

Organization of this subsection
(1) Mapping for HiRDB
(2) Mapping list for Oracle

(1) Mapping for HiRDB

The following table describes the mapping of the CMP field and database for HiRDB.

In the following table, Java data type is the data type of Java supported by CMP, JDBC data type is the java.sql.Types. data type of the JDBC corresponding to the data type of Java, and SQL data type is the DB column type recommended for mapping with the Java data type:

Table 2-11 Mapping of the CMP field and database (when using HiRDB)

Java data typeJDBC data typeSQL data type
booleanSMALLINTSMALLINT
java.lang.Boolean
byteSMALLINTSMALLINT
java.lang.Byte
char#1CHARCHAR(4)
java.lang.Character#1
shortSMALLINTSMALLINT
java.lang.Short
intINTEGERINTEGER
java.lang.Integer
longDECIMALDECIMAL(22)
java.lang.Long
floatREALREAL, SMALLFLT
java.lang.Float
doubleFLOATDOUBLE PRECISION
java.lang.Double
byte[]#2LONGVARBINARYBLOB
java.lang.String#1VARCHARVARCHAR(m)
CHAR(n)
MVARCHAR(m)
MCHAR(n)
NVARCHAR(x)
NCHAR(y)#3
java.math.BigDecimalDECIMALDECIMAL(m,n)#4
java.sql.DateDATEDATE#5
java.sql.TimeTIMETIME
java.sql.TimeStamp#6CHARCHAR(29)
Serializable type#2LONGVARBINARYBLOB
#1
For details on the precautions to be taken when using the Fixed-length string SQL type, see 2.4.3 Precautions for using CMP.
#2
HiRDB BLOB maximum value 2147483647 bytes
However, the maximum data size that can be handled depends on the upper limit for the JDBC driver. When you use HiRDB Type4 JDBC Driver, there are no JDBC driver-based restrictions.
#3
The following are the respective ranges of m, n, x, and y:
m: 1 to 32000, n: 1 to 30000, x: 1 to 16000, y: 1 to 15000
#4
The following are the respective ranges of m and n:
m: 1 to 29, n: 1 to 29
#5
The DATE range is from 0001/01/01 to 9999/12/31.
#6
Saved as a string with the format yyyy-mm-dd hh:mm:ss.fffffffff (JDBC date escape).

(2) Mapping list for Oracle

The following table describes the mapping of the CMP field and the database for Oracle.

In the following table, Java data type is the data type of Java supported by CMP, JDBC data type is the java.sql.Types. data type of the JDBC corresponding to the data type of Java, and SQL data type is the DB column type that is recommended for the mapping with the Java data type:

Table 2-12 Mapping of the CMP field and database (when using Oracle)

Java data typeJDBC data typeSQL data type
booleanNUMERICNUMBER(38)
java.lang.Boolean
byteNUMERICNUMBER(38)
java.lang.Byte
char#1CHARCHAR(4)
java.lang.Character#1
shortNUMERICNUMBER(38)
java.lang.Short
intNUMERICNUMBER(38)
java.lang.Integer
longNUMERICNUMBER(22)
java.lang.Long
floatNUMERICNUMBER
java.lang.Float
double#2FLOATFLOAT(126)
java.lang.Double#2
byte[]#3LONGVARBINARYLONG RAW
java.lang.String#1VARCHARVARCHAR(m)
CHAR(n)
LONG#4
java.math.BigDecimalNUMERICNUMBER(m,n)#5
java.sql.DateDATEDATE#6#7
java.sql.TimeCHARCHAR(8)#8
java.sql.TimeStampTimeStampDATE#7 #9
Serializable type#3LONGVARBINARYLONG RAW
Note:
The BLOB data type mapped in java.sql.Types.BLOB and the CLOB data type mapped in java.spl.Types.CLOB cannot be handled.
#1
For details on the precautions to be taken for using the Fixed-length string SQL type, see 2.4.3 Precautions for using CMP.
#2
Range of Oracle FLOAT(126) 1E-125 to 9.9 ... 9E125
The value might be rounded off.
#3
Oracle LONG RAW maximum value 2 gigabytes.
However, the maximum data size that can be handled depends on the upper limit for the JDBC driver.
#4
The following are the respective ranges of m and n:
m = 1 to 4000, n = 1 to 2000
Furthermore, if "" (blank string of zero length) is saved in Oracle, the value will be converted to NULL.
#5
The following are the respective ranges of m and n:
m = 1 to 38, n = -84 to 127
#6
The DATE range is from -4712/01/01 to 9999/12/31.
#7
The minus value cannot be handled correctly between Java-JDBC drivers for data corresponding to B.C (Before Christ). Therefore, the value cannot be guaranteed.
#8
Saved as a string with format hh:mm:ss (JDBC date escape).
#9
The range of DATE is from -4712/01/01 00:00:00 to 9999/12/31 23:59:59.