title: How to check if exists when using CrudRepository#getOne()
body: <p>I have a <code>Document</code> entity. To edit a document you must acquire a <code>DocumentLock</code>.</p>
  
  <p>Request API to edit a document looks like below. <code>edit=true</code> allows to fetch the record from database with 'FOR UPDATE`.</p>
  
  <pre><code>GET /api/document/123?edit=true
  </code></pre>
  
  <p>In Back end side, we do like this (of course over simplified),</p>
  
  <pre><code>Document document = documentRepository.getOne(documentId)    //&lt;--- (1)
  
  if(document == null){                                        //&lt;--- (2) This is always false
     //Throw exception
  }
  
  DocumentLock dl = DocumentLock.builder()
                    .lockedBy(user)
                    .lockedAt(NOW)
                    .document(document)
                    .build()
  
  documentLockRepository.save(dl);
  
  </code></pre>
  
  <p>We are using <code>getOne()</code> because we do not need to fetch whole document from database, we are just creating a relation with <code>DocumentLock</code> object.</p>
  
  <p>Question is, how to ensure the document actually exists? Because <code>getOne()</code> will always return the proxy and I do not see any obvious way to check if the record exists in databse.</p>
  
  <p><strong>Versions:</strong></p>
  
  <ul>
  <li>spring-data-jpa: 2.2.6.RELEASE</li>
  <li>hibernate: 5.4.12</li>
  </ul>
  
  <p><strong>Update</strong>: removed additional questions.</p>