
|
If you were logged in you would be able to see more operations.
|
|
|
| Resolution Date: |
08/Nov/07 03:48 PM
|
|
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:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<Code>
............
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("<Before update> ");
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("<After update> ");
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");
}
............
</Code
|
|
Description
|
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:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<Code>
............
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("<Before update> ");
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("<After update> ");
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");
}
............
</Code |
Show » |
made changes - 08/Oct/06 09:12 AM
| Field |
Original Value |
New Value |
|
Component/s
|
|
Runtime
[ 12310808
]
|
|
Component/s
|
|
Village
[ 12311399
]
|
made changes - 08/Nov/07 03:42 PM
|
Assignee
|
|
CG Monroe
[ monroe
]
|
made changes - 08/Nov/07 03:48 PM
|
Status
|
Open
[ 1
]
|
Resolved
[ 5
]
|
|
Fix Version/s
|
|
3.3-RC3
[ 12312398
]
|
|
Resolution
|
|
Fixed
[ 1
]
|
made changes - 14/Nov/07 06:32 PM
|
Status
|
Resolved
[ 5
]
|
Closed
[ 6
]
|
|