Spring Data MongoDB
  1. Spring Data MongoDB
  2. DATAMONGO-171

IllegalArgumentException when persisting entity with BigDecimal field

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0 M2, 1.0 M3
    • Fix Version/s: 1.0 M4
    • Component/s: Mapping
    • Labels:
      None

      Description

      Problems persisting entity with BigDecimal field.

      BigDecimal is not supported by MongoDB - see

      http://osdir.com/ml/mongodb-user/2011-05/msg01418.html

      Here is part of a stack trace:
      java.lang.IllegalArgumentException: can't serialize class java.math.BigDecimal
      at org.bson.BSONEncoder.putNumber(BSONEncoder.java:316)
      at org.bson.BSONEncoder._putObjectField(BSONEncoder.java:167)
      at org.bson.BSONEncoder.putObject(BSONEncoder.java:123)
      at org.bson.BSONEncoder.putObject(BSONEncoder.java:69)
      at com.mongodb.OutMessage.putObject(OutMessage.java:189)
      at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:245)
      at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:209)
      at com.mongodb.DBCollection.insert(DBCollection.java:82)
      at org.springframework.data.document.mongodb.MongoTemplate$9.doInCollection(MongoTemplate.java:835)
      at org.springframework.data.document.mongodb.MongoTemplate.execute(MongoTemplate.java:363)
      at org.springframework.data.document.mongodb.MongoTemplate.insertDBObject(MongoTemplate.java:830)
      at org.springframework.data.document.mongodb.MongoTemplate.doInsert(MongoTemplate.java:694)
      at org.springframework.data.document.mongodb.MongoTemplate.insert(MongoTemplate.java:648)
      at org.springframework.data.document.mongodb.MongoTemplate.insert(MongoTemplate.java:636)

      Looks like we removed Converter issues around BigDecimal in DATACMNS-42 and we have BigDecimal as part of SIMPLE_TYPES. So now we get this exception when the driver tries to write the BSON value.

      We probably need a converter that can handle this out of the box.

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Oliver Gierke
              Reporter:
              Thomas Risberg
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0d
                0d
                Remaining:
                Remaining Estimate - 0d
                0d
                Logged:
                Time Spent - 1h
                1h