Chapter 8 Creating J2EE Applications for BEA WebLogic


Supported Data Types

The following table provides a list of the Java data types for CMP fields used in WebLogic Server and shows how they map to the Oracle extensions for the standard SQL data types.

Java Types for CMP Fields Oracle Data Types
Float NUMBER
Int INTEGER
Long NUMBER
Short SMALLINT
java.lang.String VARCHAR/VARCHAR2
java.lang.Boolean SMALLINT
java.lang.Byte SMALLINT
java.lang.Character SMALLINT
java.lang.Double NUMBER
java.lang.Float NUMBER
java.lang.Integer INTEGER
java.lang.Long NUMBER
java.lang.Short SMALLINT
java.sql.Date DATE
java.sql.Time DATE
java.sql.Timestamp DATE
java.math.BigDecimal NUMBER
byte[] RAW, LONG RAW
Serializable RAW, LONG RAW

The SQL CHAR data type should not be used for database columns that are mapped to cmp fields. This is especially important for fields that are part of the primary key, because padding blanks that are returned by the JDBC driver can cause equality comparisons to fail when they should not. Use the SQL VARCHAR data type instead of SQL CHAR.

A cmp field of type byte[] cannot be used as a primary key unless it is wrapped in a user-defined primary key class that provides meaningful equals() and hashCode() methods. This is because the byte[] class does not provide useful equals/hashCode methods.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.