[jboss-user] [EJB 3.0] - EJB3 RC9 and BigDecimal/monetary issues
dhartford
do-not-reply at jboss.com
Wed Oct 4 12:04:34 EDT 2006
Hey all,
Using EJB3 RC9-FD patch on 4.0.4.GA Jboss AS.
Trying to handle financial calculations and outside of database versions for querying calculations, I'm definately having problems on the POJO side.
| public class SampleBean implements Serializable {
| ...
| @javax.persistence.Column(precision=8, scale=2)
| public BigDecimal getAmountPaid() {
| return amountPaid;
| }
|
After persisting data to the database (with the database fields configured as Decimal(8,2) on both Mysql and Postgresql), the return results are not 'accurate', or as expected.
After setting a value of '58.11' and persisting to the database, then trying to retrieve after a Query (i.e. completely new object as the other has been cleaned up):
| System.out.println(SampleBean.getAmountPaid());
| -->58.1099999999999994315658113919198513031005859375
|
In the database, it stores correctly. Query-level mathimatical calculations are working correctly (assuming the database doesn't use floating point optimizations on Decimal fields, such as Mysql => 5.0.3). But retrieval of the value, EVEN WITH SCALE SET, is not working as expected.
Is there something different I should be doing for handling monetary amounts in EJB3/JPA?
-D
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976067#3976067
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976067
More information about the jboss-user
mailing list