java - How to convert BigDecimal to Double in spring-data-mongodb framework -


Spring data Mongo DB mapping converts BigDeselMail by default to string. However, I want them to be converted into double as Mangondo. After this, it is necessary to ask questions on this field (compare questions / aggregation questions) How can I get my own converter (BigDiclotod Double / Double-To-Big Decimal) to do this?

How can you add your own converters here:

  & Lt; Bean id = "MangoTemplate" class = "org.springframework.data.mongodb.core.MongoTemplate" & gt; & Lt; Constructor-arg referee = "Mongo DBFCT" /> & Lt; Constructor-arg referee = "mapping conveyor" /> & Lt; Property Name = "Write Concurrent" & gt; & Lt; Usage: Constant Fixed Field = "com.mongodb.WriteConcern.FSYNC_SAFE" /> & Lt; / Property & gt; & Lt; Property Name = "ResultChecking Written" & gt; & Lt; Util: constant steady field = "org.springframework.data.mongodb.core.WriteResultChecking.EXCEPTION" /> & Lt; / Property & gt; & Lt; / Bean & gt; & Lt; Mongo: mapping-converter id = "mapping conveyor" & gt; & Lt; Mongo: custom-converters base-package = "com.vladmihalcea. **. Mongo.converter" /> & Lt; / Mongo: Mapping Converter & gt;  

Now your converters will look like this:

  @Component public class DoubleTwo Bidectic Converter converter applies  

Before I got the converter I found:

  update test.product query: {_id: 123} Update: {_id: 123, _class: "Com.vladmihalcea.mongo.model.Product", Name: "TV", Quantity: "10", Discount: "12.34", Version: 0 nscanned: Happy: 1 Upcent: 1 Key Update: 0 Locks (Micro ) W: 49328 50ms  

After adding converters:

  update test.product query: {_id: 123} update: {_id: 123, _class : "Com .80admahalcea.mongo.model.Product", Name: "TV", volume: "10", discount: 12.34, version nupcated: 1 upstate: 1 key update: 0 locks (micros) w: 64689 65ms < / Code> 

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -