When you choose a value class for a particular attribute, you sometimes do not provide Enterprise Objects with all the information the JDBC adaptor needs to negotiate with the data source.
For example, when you specify Number as the value class for
a particular attribute, you are telling Enterprise Objects to use java.lang.Number
,
which is an abstract class. This is where the value type characteristic
steps in. It specifies the exact class an attribute should map to.
The possible value types for numeric attributes are as follows(note case):
b
java.lang.Byte
s
java.lang.Short
i
java.lang.Integer
l
java.lang.Long
f
java.lang.Float
d
java.lang.Double
B
java.math.BigDecimal
c
java.lang.Boolean
The value type also specifies which JDBC methods are used
to send and retrieve the data to and from the database. These value
types affect which method the java.sql.PreparedStatement
object
uses to transfer text data between the database and the JDBC adaptor.
For attributes with a value class of String, the following value
types are defined:
setString
if
the text is less than the databases advertised maximum varchar
length
and setCharacterStream
if it is too large.
If the database fails to advertise a maximum length, the default
is 256 characters.S
uses setString
regardless
of the texts length.C
uses setCharacterString
regardless
of the texts length.E
converts the
text into raw UTF-8 bytes and then uses setBinaryStream
to
save them in a binary-typed column in the database.c
tells the adaptor
to generate SQL using RTRIM to strip off all trailing spaces.Database columns of type char
hold
string values that are right-padded with spaces to the width of
the column. String values in Enterprise Objects, however, normally
do not have trailing spaces for performance and other efficiency
reasons. An attribute that maps to an external type of char
should
have a value type of c
to
tell the JDBC adaptor to trim trailing spaces when fetching values
that correspond to that attribute. If the value type is left blank for
attributes that map to an external type of char
,
then no trimming occurs. Attributes that map to varchar
columns
are never trimmed, regardless of value type.
S
is the appropriate
value type for most text columns. C
is
good for columns that usually contain large amounts of data. c
should
be used when trailing spaces are not significant in a char
column.
It is not recommended to use E
, except
when absolutely necessary. It is the databases responsibility
to handle text encoding issues and using E
usually
indicates that the database is not properly configured.
For attributes with a value class of NSTimestamp, the following value types are defined:
getObject
on
the java.sql.ResultSet
object
and setObject
on the java.sql.PreparedStatement
object.
It assumes the database can provide a value compatible with a java.sql.Timestamp
object.D
java.util.Date
uses setDate
and getDate
.t
java.sql.Time
uses getTime
and setTime
.T
java.sql.Timestamp
uses getTimestamp
and setTimestamp
.M
use in place
of D
if using Microsoft
SQL Server. Supports only java.sql.Date
.