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

converter is not used when performing distinct query

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Works as Designed
    • Affects Version/s: 1.9.5 (Hopper SR5)
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      when performing:

      Query query = new Query();
              query.addCriteria(where(FOO.INSTANT_START_FIELD).gte(startTime));
              query.addCriteria(where(FOO.INSTANT_END_FIELD).lte(endTime));
              mongoTemplate.getCollection(COLLECTION_NAME)).distinct(FOO.FIELD), query.getQueryObject());
      

      and the startTime & endTime fields are Instants, we will get the following exception:

      java.lang.IllegalArgumentException: can't serialize class java.time.Instant
      	at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:299) ~[mongo-java-driver-2.14.3.jar:na]
      	at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194) ~[mongo-java-driver-2.14.3.jar:na]
      	at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:255) ~[mongo-java-driver-2.14.3.jar:na]
      	at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194) ~[mongo-java-driver-2.14.3.jar:na]
      	at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:255) ~[mongo-java-driver-2.14.3.jar:na]
      	at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194) ~[mongo-java-driver-2.14.3.jar:na]
      	at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:136) ~[mongo-java-driver-2.14.3.jar:na]
      	at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:36) ~[mongo-java-driver-2.14.3.jar:na]
      	at com.mongodb.OutMessage.putObject(OutMessage.java:289) ~[mongo-java-driver-2.14.3.jar:na]
      	at com.mongodb.OutMessage.writeQuery(OutMessage.java:211) ~[mongo-java-driver-2.14.3.jar:na]
      	at com.mongodb.OutMessage.query(OutMessage.java:86) ~[mongo-java-driver-2.14.3.jar:na]
      	at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:83) ~[mongo-java-driver-2.14.3.jar:na]
      	at com.mongodb.DB.command(DB.java:320) ~[mongo-java-driver-2.14.3.jar:na]
      	at com.mongodb.DB.command(DB.java:299) ~[mongo-java-driver-2.14.3.jar:na]
      	at com.mongodb.DBCollection.distinct(DBCollection.java:1640) ~[mongo-java-driver-2.14.3.jar:na]
      	at com.mongodb.DBCollection.distinct(DBCollection.java:1620) ~[mongo-java-driver-2.14.3.jar:na]
      	at 
      

      i think a useage of JSR310 Converter is missing when using distinct queries.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cstrobl Christoph Strobl
                Reporter:
                schosterbarak schoster barak
                Last updater:
                Christoph Strobl
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: