Hi Danilo,

Can't say I have much confidence in Sybase providing a permanent solution
given your experience. We'll stick with the OJB fix for now. The
ps.setBigDecimal() works also. 

Cheers
Stuart

-----Original Message-----
From: Danilo Tommasina [mailto:[EMAIL PROTECTED]
Sent: Friday, 26 March 2004 11:41 PM
To: OJB Users List
Subject: Re: Loss of precsion with PersistenceBroker.store() and
BigDecima l on Sybase.


Hi,

We have the same problem with Sybase, the bug seems not to be really an 
OJB problem it is a bug in the JDBC dirver, however doing a special 
handling for BigDecimal in OJB may be a good workaround.

The bug appears in several releases of the Sybase drivers and appears 
and disappears in different builds of the same driver version.
Driver file jconn2_v55_B25089.jar (also version 5.5 Build 25089) works 
correctly for us. In the following release build, the bug is still 
present. For some reason the bug seems to be fixed and reappear in new 
driver releases on a regular basis, this is very annoying since we do 
not always have the control over wich driver releases our customer are 
using :(
Probably using a ps.setBigDecimal(...) call (instead of 
ps.setObject(...) ) if sqlType is equal to BIG_DECIMAL would solve the 
problem.

cheers
danilo

> Hi Stuart,
> 
> do we need this patch for both Sybase versions (Sybase ASA, Sybase ASE)?
> 
> regards,
> Armin
> 
> Stuart Heriot wrote:
> 
>> 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
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


-- 
Danilo Tommasina, Dipl. Ing. FH Telecom
Software Engineer
RCS Riskmanagement Concepts Systems AG
Technoparkstrasse 1
CH-8005 Zuerich
T: +41 1 445 29 08
[EMAIL PROTECTED]
www.risksys.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to