Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 35471 invoked from network); 18 Aug 2006 15:05:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Aug 2006 15:05:13 -0000 Received: (qmail 16690 invoked by uid 500); 18 Aug 2006 15:05:13 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 16674 invoked by uid 500); 18 Aug 2006 15:05:13 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 16663 invoked by uid 99); 18 Aug 2006 15:05:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Aug 2006 08:05:13 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Aug 2006 08:05:12 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 085C641001F for ; Fri, 18 Aug 2006 15:02:14 +0000 (GMT) Message-ID: <14685065.1155913334029.JavaMail.jira@brutus> Date: Fri, 18 Aug 2006 08:02:14 -0700 (PDT) From: "Sudhakar Pandey (JIRA)" To: torque-dev@db.apache.org Subject: [jira] Created: (TORQUE-53) Inserting wrong data if data type is Double and 0(zero) is the last digit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Inserting wrong data if data type is Double and 0(zero) is the last digit ------------------------------------------------------------------------- Key: TORQUE-53 URL: http://issues.apache.org/jira/browse/TORQUE-53 Project: Torque Issue Type: Bug Affects Versions: 3.2 Environment: Windows NT Reporter: Sudhakar Pandey Problem: Torque is inserting wrong data in the database for Double type. Database description ~~~~~~~~~~~~~~~~~ Database: Oracle 10g Oracle JDBC version: 10.2.0.1.0 Table Name: Bank_Account Column Name: Current_Balance Column dataType: NUMBER(15,4) When I am trying to enter a value new Double(1234567890) it insert/update 12.3456 in the database. This happens only if the number of digits are more than 7 and last digit is 0(zero). I have tried updating using directly PreparedStatement and it just worked fine. Problem comes only with Torque. Following is the program I have used for varification: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ............ public static void main(String argv[]) { TorqueInitializer.init(); Connection db_connection = null; db_connection = Common.getConnection(); if (db_connection == null) { System.out.println("Unable to get dbConnection"); } try { BankAccount bankAccount = showCurrentBalance(db_connection); long value = 12345l; for (int i = 5; i < 11; i++, value = ((value * 10) + i)) { System.out.println("Value=" + value); System.out.print(" "); bankAccount = showCurrentBalance(db_connection); if (updateUsingPrepStat) updateCurrentBalanceUsingPStat(db_connection, new Double( value * 10)); else updateCurrentBalanceUsingTorque(bankAccount, db_connection, new Double(value * 10)); System.out.print(" "); bankAccount = showCurrentBalance(db_connection); } } catch (Exception e) { e.printStackTrace(); } finally { if (db_connection != null) try { db_connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } public static BankAccount showCurrentBalance(Connection db_connection) { try { Criteria c = new Criteria(); c.add(BankAccountPeer.BANK_ACCOUNT_ID, new Long(1523764)); List list = BankAccountPeer.doSelect(c, db_connection); BankAccount bankAccount = (BankAccount) list.get(0); System.out.println("Current account balance: " + bankAccount.getCurrentBalance()); return bankAccount; } catch (TorqueException e) { e.printStackTrace(); } return null; } public static void updateCurrentBalanceUsingTorque(BankAccount bankAccount, Connection db_connection, Double value) throws Exception { bankAccount.setCurrentBalance(value); bankAccount.save(db_connection, "ibdv70"); } ............