title: Hibernate get entity by non-primary key and update it + Spring mvc
body: <p>When I retrieve an object using its id and I change its properties and update it, everything work fine but when I get my objects using their name + version and update them, none of the changes save in the database. Could you please someone let me know what is the problem?!</p>
  
  <p>// Get by id</p>
  
  <pre><code>public PdfDocument get(Long id) {
      return (PdfDocument) session().get(PdfDocument.class, id);
  }
  </code></pre>
  
  <p>// Get by name + version</p>
  
  <pre><code>public PdfDocument get(String name, int version) {
      Criteria criteria = session().createCriteria(PdfDocument.class);
      criteria.add(Restrictions.eq("name", name));
      criteria.add(Restrictions.eq("version", version));
      return ((PdfDocument) criteria.uniqueResult()) ;
  }
  </code></pre>
  
  <p>// update </p>
  
  <pre><code>public void update(PdfDocument PdfDocument) {
      session().saveOrUpdate(PdfDocument);
  }
  </code></pre>