devbliss/mongojack — pull request #72 by rmalchow (2014-10-27 06:32:26+00:00)
Title: test case for queries with "in"

hi,

i already sent a pull request a while ago - this time, the test case comes first. the issue is that the wrong serializer is used for serializing a query under certain circumstances, in this case:

- the document has a collection with the name "simpleList" (which is, on the java side, a java.util.List)
- i try to do an "$in" query, passing in the name of the field ("simpleList") and one or more values.
- the error happens somewhere in serialization utils - the serializer for the TYPE of the field is used, so the utils try to serialize a string ("simpleList") with StringCollectionSerializer, resulting in an exception:

java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection
at com.fasterxml.jackson.databind.ser.impl.StringCollectionSerializer.serialize(StringCollectionSerializer.java:24)
at org.mongojack.internal.util.SerializationUtils.serializeQueryField(SerializationUtils.java:257)
at org.mongojack.internal.util.SerializationUtils.serializeQueryCondition(SerializationUtils.java:174)
at org.mongojack.internal.util.SerializationUtils.serializeQueryCondition(SerializationUtils.java:185)
at org.mongojack.internal.util.SerializationUtils.serializeQuery(SerializationUtils.java:146)
at org.mongojack.internal.util.SerializationUtils.serializeQueryCondition(SerializationUtils.java:195)
at org.mongojack.internal.util.SerializationUtils.serializeQuery(SerializationUtils.java:146)
at org.mongojack.internal.util.SerializationUtils.serializeQuery(SerializationUtils.java:134)
at org.mongojack.JacksonDBCollection.serializeQuery(JacksonDBCollection.java:2313)
at org.mongojack.JacksonDBCollection.find(JacksonDBCollection.java:1180)
[...]