On Fri, Dec 21, 2012 at 2:35 PM, CSharper <[email protected]>wrote:

> Hi,
>
> rounding should be part of your domain logic and not driven by truncation
> or some magic rounding on the mapping level.
> So best handle the rounding directly in the property setter or somewhere
> in the domain logic even before setting the property.
>
> Otherwise you may get strange results if you use the property value for
> further calculations. When freshly setting the property to 112,355 and
> doing some calculation, e.g. *10 you get an amount of 1223,55.
> But after reading the rounded value from the database, the same
> calculation will give you 1223,60. This violates the principle that
> persistence should be somewhat transparent.
>
>
>
> Am Dienstag, 18. Dezember 2012 17:30:45 UTC+1 schrieb Iiro Rahkonen:
>
>> Hi!
>>
>> I have an issue with rounding numbers to the database.
>>
>> I have a mapping property and the database has datatype decimal(18,2) on
>> the field.
>> <property name="Amount" column="Amount" not-null="true" precision="18"
>> scale="2" />
>>
>> I would like to add a rounding function to the property mapping so that
>> number like 112,355 would be 112,36 instead of the result of the current
>> truncation of the number 112,35.
>>
>> Basicly use the round function in .NET or SQL Server when inserting the
>> value. Is this possible in the mapping file or do I have to do the change
>> everywhere where the value is inserted in the database?
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/nhusers/-/Cl8gNWSjfyAJ.
>
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>



-- 
PRIYANKA

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to