全部
我们使用的是NHiberate 2.1,我们在其中存储十进制值(汇率),例如123.1234567到小数点后7位
We were using NHiberate 2.1 where we are storing decimal values (exchange rates) e.g. 123.1234567 to 7 decimal places
我们正在使用默认的映射样式来映射类型:
We are mapping the type using default mapping style:
<property name="ExchangeRate" not-null="true" />但是,当我们升级到NHibernate 3.0时,以上值将保存为123.1234500.
However when we upgrade to NHibernate 3.0 the value above is saved as 123.1234500.
尽管似乎确实详细说明了问题[NH-1594],十进制的默认值为DECIMAL(19,5)
It does not specify this change in behaviour in the 3.0 release notes although it does seem to detail that in issue [NH-1594], the default value for decimal is DECIMAL(19,5)
我们有一个解决方案,即指定以下映射:
We have a solution i.e. specify the following mapping:
<property name="ExchangeRate" type="decimal(10,7) not-null="true" />我需要知道此解决方案是解决此问题的正确方法吗? 另外,为什么行为发生功能上的变化,且舍入在2.1和3.0之间?
I need to know is this solution the right way to solve this issue? Also, why is there a functional change in behaviour with rounding between 2.1 and 3.0?
干杯
比利堆栈
推荐答案可以,但这是更干净的IMO:
That works, but this is cleaner IMO:
<property name="ExchangeRate" precision="10" scale="7" />属性类型暗含一个非空的十进制.
A not-null decimal is implied by the property type.
更多推荐
NHibernate 3.0将小数点后四舍五入到小数点后五位
发布评论