Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-1037

Serialization exception in Query class with enumerations

    Details

    • Type: Bug
    • Status: Waiting for Feedback
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.5.2 (Dijkstra SR2)
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      When enum value is used as part of Criteria object, when Query is throwing exception, serialization is failing.
      Following is stacktrace:

      java.lang.RuntimeException: json can't serialize type : class mypackage.MyClass$UserStatus
      	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:77)
      	at com.mongodb.util.JSONSerializers$MapSerializer.serialize(JSONSerializers.java:317)
      	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:79)
      	at com.mongodb.util.JSONSerializers$MapSerializer.serialize(JSONSerializers.java:317)
      	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:79)
      	at com.mongodb.util.JSON.serialize(JSON.java:55)
      	at com.mongodb.util.JSON.serialize(JSON.java:40)
      	at com.mongodb.BasicDBObject.toString(BasicDBObject.java:83)
      	at java.lang.String.valueOf(String.java:2854)
      	at java.lang.StringBuilder.append(StringBuilder.java:128)
      	at org.springframework.data.mongodb.core.query.Query.addCriteria(Query.java:88)
      

      Also on side note (may qualify for another bug which caused above exception to appear) : MongoDB allows same multiple criteria on same key, For e.g., db.business.find({status:'Active', status:{$ne:'InActive'}},

      {status:1}

      ) is working fine from mongodb console. If I try same thing using Criteria it causes exception. I can work around the problem, but in certain cases I would like to allow this where criteria is prepared dynamically.

        Attachments

          Activity

            People

            • Assignee:
              olivergierke Oliver Gierke
              Reporter:
              poornasubhash Poorna Subhash
              Last updater:
              Oliver Gierke
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: