Subject Changes Support for setObject in the direct client driver
Author Goedhart, Andrew
The is a problem with the way in which setObject is handled inthe new fields
model.

The error messages are not consistent with one another and the conversions
supported using the setMethods are not available using the setObject method.

This is problematic and make it impossible to use the driver with JBoss
which make extensive use of the setObject method. The real problem occurs
when you have entity beans with boolean fields. No setObject method converts
for any field will convert a Boolean object into a value for the field and
if you are using a SmallInt or INteger field then you get the wrong error
message as well (i.e. not a Object coversion error message)

The fix is to create a setObject method in the FBField base class as
follows:

/**
* Checks the object type and passes it off to the associated set method
if possible.
*
*@param value The object to whose value the field is to be set to.
*@exception SQLException Thrown on a conversion error
*/
void setObject(Object value) throws SQLException {
if (value == null) {
setNull(true);
return;
}
if (value instanceof InputStream) {
setBinaryStream((InputStream) value);
} else if (value instanceof BigDecimal) {
setBigDecimal((BigDecimal) value);
} else if (value instanceof Blob) {
setBinaryStream(((FBBlob) value).getBinaryStream());
} else if (value instanceof Boolean) {
setBoolean(((Boolean) value).booleanValue());
} else if (value instanceof Byte) {
setByte(((Byte) value).byteValue());
} else if (value instanceof byte[]) {
setBytes((byte[]) value);
} else if (value instanceof Date) {
setDate((Date) value);
} else if (value instanceof Double) {
setDouble(((Double) value).doubleValue());
} else if (value instanceof Float) {
setFloat(((Float) value).floatValue());
} else if (value instanceof Integer) {
setInteger(((Integer) value).intValue());
} else if (value instanceof Long) {
setLong(((Long) value).longValue());
} else if (value instanceof Short) {
setShort(((Short) value).shortValue());
} else if (value instanceof String) {
setString((String) value);
} else if (value instanceof Time) {
setTime((Time) value);
} else if (value instanceof Timestamp) {
setTimestamp((Timestamp) value);
} else {
throw (SQLException) createException(
OBJECT_CONVERSION_ERROR).fillInStackTrace();
}
}

The next step is to delete all set object methods in the descendant classes

This creates a consistent conversion mechanism as well as having only one
conversion in the descendant class.

Attached is a updated set of files for the FBxxxxFields and FBField.
Includes the changes made by rrokytskyy on Wed Feb 20 23:30:03 2002 UTC
All the tests for org.firebirdsql.jdbc pass successfully with the new
changes.
<<FieldUpdate.zip>>
Could someone update the archive with the changes supplied. I am behind a
corporate firewall and given up trying to get our IS department to let me
drill holes through it. Thus I have no access to archives except by
painstakingly downloading each file via the HTML interface
Andrew