To do this for BigDecimal I have added the following code to my
_Entity template for the attributes:
#if ($attribute.javaClassName == "BigDecimal")
if (${attribute.name} != null) {
${attribute.name} = ${attribute.name}.setScale(${attribute.scale},
RoundingMode.HALF_UP);
}
#end
It has solved all my issues with setting the scale of a value prior to
saving it to the database, and I don't believe that it has caused any
negative impacts...
Dave
On Mar 1, 2009, at 4:36 PM, Joe Moreno wrote:
Hi all,
I have set my database Scale on all floats to 7. Sometimes, due to
match or rounding, the scale goes beyond that and I get the
following exception:
[2009-03-01 13:26:28 PST] <WorkerThread3> <com.webobjects.Test>:
Exception in performActionNamed() on the action "testIt" with the
message
: com.webobjects.eoaccess.EOGeneralAdaptorException: The attribute
totalCost has a scale of 7, but the value 0.00728571 has a scale of
8: Rounding necessary
[2009-03-01 13:26:27 PST] <WorkerThread3>
com.webobjects.eoaccess.EOGeneralAdaptorException: The attribute
totalCost has a scale of 7, but the value 0.00728571
Is there a simple way to have a number automatically rounded in the
EOModel to "fit" into database?
Thanks,
Joe
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com
This email sent to webobje...@avendasora.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com