Spring Data MongoDB BigDecimal支持 [英] Spring Data MongoDB BigDecimal support

查看:267
本文介绍了Spring Data MongoDB BigDecimal支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑与Spring Data MongoDB对BigDecimal值的支持有关,有人可以帮助我了解一些有关此消息的信息吗,是否会支持这种类型,或者是否有人知道解决方法可以满足我的需求.就是这样:我正在一个项目中,我们使用MongoDB作为数据库,并使用Spring作为框架,我们想将数据库中应该用来获取货币值的字段保存为BigDecimal,我已经阅读了mongo只接受double作为浮点数,但我认为这种类型不会有用.你们能给我一些启发吗?

guys I have a doubt related to BigDecimal value support by Spring Data MongoDB, could someone help me with some news about it, if there will be support for this type, or if anyone knows a workaround to supply my needs. That's the deal: I'm working on a project where we use MongoDB as a DB and Spring as framework, we would like to save the fields where we are supposed to get money values in the database as BigDecimal, I've read that mongo only accepts double as a float number, but I don't think this type is going to be useful. Could you guys give me some light about it?

推荐答案

Spring Data MongoDB在写入时将BigDecimal值转换为String,并在读取时返回.请查看数据映射和类型转换".

Spring Data MongoDB converts BigDecimal values to String on write and back to when reading. Please have a look at the data mapping and type conversion section of the reference manual.

这篇关于Spring Data MongoDB BigDecimal支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆