title: Implementing findOne in Spring Data (MongoDB)
body: <p>I have some problems with executing findOne method of MongoOperations class, for now this method return null. My data structure in mongoDB is looking like this:</p>
  
  <pre><code>&gt; db.news.find({_id:1})
  { "_id" : 1, "title" : "first title", "text" : "first text" }
  &gt; db.news.find({_id:{$type:1}})
  { "_id" : 1, "title" : "first title", "text" : "first text" }
  </code></pre>
  
  <p>As you can see above _id field has Double type. My Java classes is looking like this:</p>
  
  <pre><code>@Repository
  public class NewsService {
  
      @Autowired
      private MongoOperations mongoOperations;
  
      public static final String COLLECTION_NAME = "news";
  
      //this method executes ok
      public List&lt;NewsEntity&gt; getAllNews() {
          return mongoOperations.findAll(NewsEntity.class, COLLECTION_NAME);
      }
  
      //but this method return null     
      public NewsEntity getNewsDetail(Long id) {
          return mongoOperations.findOne(Query.query(Criteria.where("_id").is(id)), NewsEntity.class);
      }
  </code></pre>
  
  <p>Entity class:</p>
  
  <pre><code>@Document
  public class NewsEntity {
  
   @Id
   private Long id;
   private String title;
   private String text;
  
  
   public Long getId() {
       return id;
   }
  
   public void setId(Long id) {
       this.id = id;
   }
  
   public String getTitle() {
       return title;
   }
  
   public void setTitle(String title) {
       this.title = title;
   }
  
   public String getText() {
       return text;
   }
  
   public void setText(String text) {
       this.text = text;
   } 
  }
  </code></pre>
  
  <p>And Spring controller:</p>
  
  <pre><code>@Controller
  public class MainController {
   @Autowired
   private NewsService newsService;
  
   @RequestMapping(value="/news/details/{newsId}",method = RequestMethod.GET)
   public String getNewsDetails(ModelMap model, @PathVariable("newsId") Long newsId) {
       //newsEnt is null here...
       NewsEntity newsEnt = newsService.getNewsDetail(newsId);
  
       model.addAttribute("newsDet", newsEnt);
       return "newsdetails";
   }
  }
  </code></pre>