title: Unable to execute MongoDB query with @Query annotation in Spring
body: <p>I am facing a bit weird problem while executing the query in MongoDB using spring boot.</p>
  <p>I have data set in the following formats.</p>
  <pre><code>{
      &quot;_id&quot; : &quot;602b950000f37b023411f98f&quot;,
      &quot;recepeName&quot; : &quot;testplan2&quot;,
      &quot;orderDate&quot; : &quot;2021-04-20T06:32:35Z&quot;,
      &quot;_class&quot; : &quot;com.company.ObjectData&quot;
  }
  
  {
      &quot;_id&quot; : ObjectId(&quot;607ff6a418b64b0be4bac7fd&quot;),
      &quot;recepeName&quot; : &quot;testplan2&quot;,
      &quot;orderDate&quot; : &quot;2021-04-20T06:32:35Z&quot;,
      &quot;_class&quot; : &quot;com.company.ObjectData&quot;
  } 
  </code></pre>
  <p>As you can see the difference in _id, one is <strong>&quot;_id&quot; : &quot;602b950000f37b023411f98f&quot;</strong> and another is <strong>&quot;_id&quot; : ObjectId(&quot;607ff6a418b64b0be4bac7fd&quot;)</strong>. To execute the query, I have written the following in interface</p>
  <pre><code>@Query(&quot;{ '_id' : { $in: [?0, ObjectId(?0)]}}&quot;)
  List&lt;MyObjectData&gt; findObjectDataById(String id);
  </code></pre>
  <p>But the above query return 0 results. I also tried with the following but it did not work.</p>
  <pre><code>@Query(&quot;{'$or':[ {'_id':?0}, {'_id':ObjectId(?0)} ] }&quot;)
  List&lt;MyObjectData&gt; findObjectDataById(String id);
  </code></pre>
  <p>But I am able to execute the MongoDB query in Robo3T editor with the following query</p>
  <pre><code>db.getCollection('CollName').find({&quot;_id&quot; : {&quot;$in&quot; : [ObjectId(&quot;605db41c90b901001feee9b6&quot;), &quot;605db41c90b901001feee9b6&quot;]}});
  </code></pre>
  <p>The above query works in MongoDB editor. Please help me how to achieve the similar query in Spring MongoDB.</p>
  <p>I include below the relevant classes.</p>
  <pre><code>public class ObjectDataEntity extends BaseEntity {
  
      @JsonProperty(&quot;dataId&quot;)
      @Field(&quot;dataId&quot;)
      private String projectPlanId;
  
      @JsonProperty(&quot;OrderRunDate&quot;)
      @Field(&quot;OrderRunDate&quot;)
      private String validationRunDate;
      
  }   
  
  @Data
  public class BaseEntity {
  
      @JsonProperty(&quot;_id&quot;)
      @Id
      private String id = new ObjectId().toString();
  }
  
  
  public interface ObjectDataRepo extends MongoRepository&lt;NVTValidationReportsEntity, String&gt; {
         
  //    @Query(&quot;{ '_id' : { $in: [?0, ObjectId(?0)]}}&quot;)
      @Query(&quot;{'$or':[ {'_id':?0}, {'_id':ObjectId('?0')} ] }&quot;)
      List&lt;ObjectDataEntity&gt; findObjectDataEntityById(String id);
   // ...other code   
  }
  </code></pre>