Oracle® Application Server Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 2 (10.1.2) Part No. B15505-01 |
|
![]() Previous |
![]() Next |
In defining the container-managed persistent fields in the <cmp-field>
and the primary key types, you can define simple data types and Java user classes that are serializable.
The following table provides a list of the supported simple data types, which you can provide in the persistence-type
attribute, with the mapping of these types to SQL types and to Oracle database types. None of these mappings are guaranteed to work on non-Oracle databases.
Table 5-1 Simple Data Types
Known Type (native) | SQL type | Oracle type |
---|---|---|
java.lang.String | VARCHAR(255) | VARCHAR2(255) |
java.lang.Integer[ ] | INTEGER | NUMBER(20,0) |
java.lang.Long[ ] | INTEGER | NUMBER(20,0) |
java.lang.Short[ ] | INTEGER | NUMBER(10,0) |
java.lang.Double[ ] | DOUBLE PRECISION | NUMBER(30,0) |
java.lang.Float[ ] | FLOAT | NUMBER(20,5) |
java.lang.Byte[ ] | SMALLINT | NUMBER(10,0) |
java.lang.Character[ ] | CHAR | CHAR(1) |
java.lang.Boolean[ ] | BIT | NUMBER(1,0) |
java.util.Date | DATETIME | DATE |
java.sql.Date | DATE | DATE |
java.util.Time | DATE | DATE |
java.sql.Timestamp | TIMESTAMP | TIMESTAMP |
java.lang.String | CLOB | CLOB |
char[ ] | CLOB | CLOB |
byte[ ] | BLOB | BLOB |
java.io.Serializable (4KB limit) | LONGVARBINARY | BLOB |
Note: You can modify the mapping of these data types in theconfig/database-schema/<db>.xml XML configuration files.
|
The Date
and Time
map to DATE
in the database, because the DATE
contains the time. The Timestamp
, however, maps to TIMESTAMP
in the database, which gives the time in nanoseconds.
Mapping java.sql.CLOB
and java.sql.BLOB
directly is not currently supported because these objects are not serializable. However you can map a String or char[]
and byte[]
to database column type CLOB and BLOB respectively. Mapping a char[]
to a CLOB or a byte[]
to a BLOB can only be done with an Oracle database. The Oracle JDBC API was modified to handle this operation.
There is a 4 KB limit when mapping a serialized object to a BLOB type over the JDBC Thin driver.
When String and char[]
variables map to a VARCHAR2 in the database, it can only hold up to 2K. However, you can map String object or char[]
larger than 2K to a CLOB by doing the following:
The bean implementation uses the String or char[]
objects.
The persistence-type
attribute of the <cmp-field-mapping>
element defines the object as a CLOB, as follows:
<cmp-field-mapping name="stringdata" persistence-name="stringdata" persistence-type="CLOB" />
In the same manner, you can map a byte[]
in the bean implementation to a BLOB, as follows:
<cmp-field-mapping name="bytedata" persistence-name="bytedata" persistence-type="BLOB" />
In addition to simple data types, you can define user classes that implement Serializable
. These classes are stored in a BLOB in the database.