Here's what we found fixes the problem. It sort of make sense except for the error message.
In the bean, we had set a default value for the BigDecimal field. If we call the proc with that field as a null, everything works, and a BigDecimal value is returned with the correct value. What led us to try that is that bigDecimal is an immutable type and while the bean only sets the reference to new instances via setters, we suspected that the jdbc driver may be trying to 'reuse' the instance. However I would have expected a security exception not an arithmetic overflow in that case. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Larry Meadors Sent: Thursday, May 24, 2007 11:35 AM To: [email protected] Subject: Re: problems using stored procs on sybase So, what happens if you put the result in a Map, but don't tell iBATIS how you want it mapped? If you look at the map in a debugger, what's the type? Larry On 5/24/07, Gaer,Jeffrey J <[EMAIL PROTECTED]> wrote: > > > > > Actually, we think we have identified the problem with the result set. The > developer was calling the queryForObject method. It makes sense that this > implies a resultset being returned. Other procs that don't return result > sets are all accessed using the update method on the map. Not sure why/if > that would effect the decimal conversion. > > > > ________________________________ > > > From: Gaer,Jeffrey J > Sent: Thursday, May 24, 2007 11:19 AM > To: [EMAIL PROTECTED]; Gaer,Jeffrey J; > [email protected] > > Subject: RE: problems using stored procs on sybase > > > > > Thanks for the response Chris, > > > > As you can see from the sqlMap definition we are using only ? parameters. We > didn't have a problem getting the output parameter back ( other than the > type conversion issue), but the ibatis code was failing because it was > expecting a result set. We are not sure why that is a problem with this proc > but with none of our update proc, but are guessing it is a configuration > issue or default somewhere. The conversion issue 'floats' with the value > that is passed so we a pretty sure it is related to precision and the > conversion process. TTBOMK Ibatis does not provide a means for specifying > the precision of decimal types when building the callable. Lots of big > decimal values wind up with long fractional values because of decimal to > base conversion. > > > > ________________________________ > > > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > Sent: Thursday, May 24, 2007 10:59 AM > To: [EMAIL PROTECTED]; [email protected] > Subject: RE: problems using stored procs on sybase > > > > First, your problem with JConnect. There is documented in the JConnect > reference guide one sentence that you should never overlook. > > Executing stored procedures > > *If you execute a stored procedure in a CallableStatement object that > represents parameter values as question marks, you get better performance > than if you use both question marks and literal values for parameters. > Further, if you mix literals and question marks, you cannot use output > parameters with a stored procedure. > > > Be certain that you are not mixing literals with the question marks when > executing the sp. > > > > > > As far as BigDecimal not mapping, I currently have defined in one class a > BigDecimal field that I am mapping in my SQLMap from a DECIMAL jdbc type > without any issues. The database has this field defined as Money. > > > result column="unit_price" property="unitPrice" jdbcType="DECIMAL" > > I would recommend looking through the JConnect Programmers Guide to ensure > that you are mapping things correctly. There is a great deal of information > in the guide and I can say from experience that "The Devil is in the > details." There are many little "gotchas" in this guide that you must pay > attention to. > > > ________________________________ > > > From: "Gaer,Jeffrey J" <[EMAIL PROTECTED]> [mailto:"Gaer,Jeffrey > J" <[EMAIL PROTECTED]>] > Sent: Thursday, May 24, 2007 7:59 AM > To: [email protected] > Subject: problems using stored procs on sybase > > Running java 1.4.2 and Sybase jconnect driver ( I think we are version 12.0 > ) we had two problems running a particular stored proc. > > > > The first was a null pointer exception processing the results. The proc set > an output value but did not return a result set. Adding a 'dummy' result > set to the proc eliminated the problem. > > -------------------- > > Caused by: java.lang.NullPointerException > > at > com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.jav a:375) > > at > com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExec utor.java:291) > > at > com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuer y(ProcedureStatement.java:34) > > ----------------------- > > > > The other occurs when using sql DECIMAL types. We tried using both > BigDecimal and Double as the java type, but get the following exception. We > were able to work around this by adding a string conversion in the proc and > passing strings. I was looking for a way to set the precession in Ibatis, > but could not find one, the precession property seems to be only available > for .net. > > > > ---------------------------------- > > --- Cause: com.sybase.jdbc2.jdbc.SybSQLException: > Arithmetic overflow during implicit conversion of DECIMAL value '2905.00' to > a NUMERIC field . > > > > Caused by: com.sybase.jdbc2.jdbc.SybSQLException: > Arithmetic overflow during implicit conversion of DECIMAL value '2905.00' to > a NUMERIC field . > > > > at > com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWith Callback(GeneralStatement.java:185) > > at > com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForO bject(GeneralStatement.java:104) > > at > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx ecutorDelegate.java:561) > > at > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx ecutorDelegate.java:536) > > at > com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSession Impl.java:93) > > at > com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientIm pl.java:70) > > > > ------------------------ > > Here's the sqlMap definition, we tried both with and without setting the > types in the result map.Thanks in advance for any insight. > > ----------------------------- > > <resultMap id="bedsResult" class="java.util.HashMap" > > > <result > > property="total_fee" > > > > column="AMOUNT"/> > > </resultMap> > > > > <parameterMap id="bedsCalcFeeParam" class="bedsFee" > > > <parameter property ="id_app" jdbcType="VARCHAR" > javaType="java.lang.String" mode="IN"/> > > <parameter property ="id_service" jdbcType="VARCHAR" > javaType="java.lang.String" mode="IN"/> > > <parameter property ="app_action_string" jdbcType="VARCHAR" > javaType="java.lang.String" mode="IN"/> > > <parameter property ="total_capacity" jdbcType="INTEGER" > javaType="java.lang.Integer" mode="IN"/> > > <parameter property ="dt_effective" jdbcType="DATE" > javaType="java.util.Date" mode="IN"/> > > <parameter property ="total_fee" > javaType="java.math.BigDecimal" jdbcType="DECIMAL" mode="INOUT"/> > > </parameterMap> > > > > <procedure id="bedsCalcFee" parameterMap="bedsCalcFeeParam" > resultClass="java.util.HashMap"> > > {call proc_calculate_fee_opa (?,?,?,?,?,?)} > > </procedure> > > > >
