title: How does Hibernate handle Blob?
body: <p>I've got a table with the following structure:</p>
  
  <pre><code>int id | blob file_to_store | int version  
  </code></pre>
  
  <p>This is how my domain works:</p>
  
  <pre><code>@Entity
  @Table(name = "FileToStore")
  public class FileToStore{
  
      @Id
      @Column(name = "id")
      private int Id;
  
      @Column(name = "version")
      private int version;
  
      @Column(name = "file_to_store")
      @Lob
      private Blob file;
  
      //gets and sets
  }
  </code></pre>
  
  <p>Sometimes I just need a file version. Like this :</p>
  
  <pre><code>FileToStore fileToStore=FileToStoreService.get(id);
  return fileToStore.getVersion();
  </code></pre>
  
  <p>Is that going to work fast or I have to write another SQL query to take version field only to avoid loading file? <a href="https://docs.oracle.com/javase/7/docs/api/java/sql/Blob.html" rel="nofollow">Oracle documentation</a> says </p>
  
  <blockquote>
    <p>Blob object contains a logical pointer to the SQL BLOB data rather
    than the data itself</p>
  </blockquote>