You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Stuart Heriot <sh...@infocomp.com> on 2004/03/29 07:14:28 UTC

RE: Loss of precsion with PersistenceBroker.store() and BigDecima l on Sybase.

I'm not sure about ASA. We only run ASE servers.

-----Original Message-----
From: Armin Waibel [mailto:arminw@apache.org]
Sent: Friday, 26 March 2004 7:12 PM
To: OJB Users List
Subject: Re: Loss of precsion with PersistenceBroker.store() and
BigDecima l on Sybase.


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:sheriot@infocomp.com]
> 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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org