I have implemented a fix for this issue locally by modifying the Sybase
Plaform dependant class (see below). I picked this up from a posting about a
similar issue with DB2. The DB2 fix, however, is not in the rc5 release. We
need a fix to be included in the official OJB release so that we don't
reintroduce this problem when implementing future releases of OJB. Is this
possible? Please advise..
Regards Stuart Heriot
package org.apache.ojb.broker.platforms;
public class PlatformSybaseASEImpl extends PlatformDefaultImpl {
/**
* Platform specific fix to BigDecimal's being truncated when stored
to Sybase db.
*/
public void setObjectForStatement(PreparedStatement ps, int index,
Object value, int sqlType) throws SQLException {
// Added code to fix problem with truncation occuring on
// BigDecimals when setObject is used in PlatformDefaultImpl
// Copied from similar fix to DB2 implementation.
if (sqlType == Types.DECIMAL) {
ps.setObject(index, value);
} else {
super.setObjectForStatement(ps, index, value,
sqlType);
}
}
/**
* Get join syntax type for this RDBMS
* one on of the constants from JoinSyntaxType interface
*/
public byte getJoinSyntaxType() {
return SYBASE_JOIN_SYNTAX;
}
}
-----Original Message-----
From: Stuart Heriot [mailto:[EMAIL PROTECTED]
Sent: Friday, 26 March 2004 9:34 AM
To: 'OJB Users List'
Subject: Loss of precsion with PersistenceBroker.store() and BigDecimal
on Sybase.
Hi,
We have come across a problem storing BigDecimals with values being
truncated and all decimal places being set to zero. Our system has a number
of value types stored with 2, 4 or 6 decimal point precision. We are using
BigDecimals rather than floats or doubles to maintain accuracy in financial
calculations within our application. Repository mapping has JDBC-TYPE set to
DECIMAL and precision set as required. Old values in the database are
retrieved Ok with the correct precision but new values we try and store are
all truncated.
I came across a posting some months ago about a similar problem with DB2 and
using prepared statements. Is there a fix for this?
Currently using OJB rc5 and a Sybase 12.5 database.
Thanks in advance...
Stuart Heriot