Patches item #656231, was opened at 2002-12-19 11:00
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376687&aid=656231&group_id=22866

Category: JBossCMP
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond (rpbrandon)
Assigned to: Nobody/Anonymous (nobody)
Summary: BigInteger is recognized as BigDecimal

Initial Comment:
JBoss recognizes a BigInteger as BigDecimal in 
JDBCCommand.java and reports error "Got a 
java.math.BigDecimal: '###' while looking 
for a java.math.BigInteger". This has been reproduced 
this with v3.0.3 and v3.0.4 both with EJB1.1 and EJB2.0.

An application stores a row in to a table and then 
retrieves the data. The table looks like this:

CREATE TABLE X (
id VARCHAR (40) NOT NULL,
bigDecimalType DECIMAL (18, 4) NOT NULL,
bigIntegerType DECIMAL (18) NOT NULL,
PRIMARY KEY (id)
);

JBoss debug output:

2002-12-17 14:35:31,543 DEBUG 
[org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand] Create 
command executing: INSERT INTO 
BigNumbersMandatory 
(bigDecimalType,bigIntegerType,id) VALUES (?,?,?)
2002-12-17 14:35:31,543 DEBUG 
[org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand] Set 
parameter: idx=1, jdbcType=DECIMAL, value=10
2002-12-17 14:35:31,543 DEBUG 
[org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand] Set 
parameter: idx=2, jdbcType=DECIMAL, value=100
2002-12-17 14:35:31,543 DEBUG 
[org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand] Set 
parameter: idx=3, jdbcType=VARCHAR, value=Piet
2002-12-17 14:35:31,558 DEBUG 
[org.jboss.ejb.plugins.jaws.jdbc.JDBCUpdateCommand] 
Rows affected = 1
2002-12-17 14:35:31,574 TRACE [EjbTier] 
BigNumbersMandatoryBean.ejbPostCreate
(BigNumbersMandatoryUpdate update)
2002-12-17 14:35:31,590 TRACE [EjbTier] 
BigNumbersMandatoryBean.ejbStore(): key=id(Piet)
2002-12-17 14:35:31,590 DEBUG 
[org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand] Load 
command executing: SELECT 
BigNumbersMandatory.id,BigNumbersMandatory.bigDeci
malType,BigNumbersMandatory.bigIntegerType FROM 
BigNumbersMandatory WHERE id=?
2002-12-17 14:35:31,590 DEBUG 
[org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand] Set 
parameter: idx=1, jdbcType=VARCHAR, value=Piet
2002-12-17 14:35:31,621 DEBUG 
[org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand] Got a 
java.math.BigDecimal: '100' while looking for a 
java.math.BigInteger


Note that in the create table script the difference 
between bigint and bigdecimal is the precision.

I looked at Solid, Informix, Oracle, InstandDB and DB2. 
They all use BigInteger and BigDecimal the same way, 
that is: A BigInteger is a BigDecimal without precision 
(on SQL table creation level). 

Proposal for function protected Object getResultObject
(ResultSet rs, int idx, Class destination) in 
JDBCCommand.java (org.jboss.ejb.plugins.jaws.jdbc)

Upon retrieving a BigDecimal when actually a BigInteger 
is expected, check if the desired type is indeed 
BigInteger. Test if the actual retrieved BigDecimal has a 
scale of zero. If this is the case, convert the BigDecimal 
to BigInteger by calling method toBigInteger() and return 
the converted type.

Attached is a zip file containing the file original 
JDBCCommand.java file and the new file with the 
proposed changes. 


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376687&aid=656231&group_id=22866


-------------------------------------------------------
This SF.NET email is sponsored by: Geek Gift Procrastinating?
Get the perfect geek gift now!  Before the Holidays pass you by.
T H I N K G E E K . C O M      http://www.thinkgeek.com/sf/
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to