title: Blob creation using Hibernate and Spring
body: <p>I'm using Spring 4.2.3, Hibernate 5.0.4, JPA 2.1 for purpose of self training in case of ORM. Today I was learning how to store <a href="https://docs.oracle.com/javase/7/docs/api/java/sql/Blob.html" rel="nofollow">Blob</a> in Oracle 11.2.0.4 DB.</p>
  
  <p>In my application I have Service and Dao layers. </p>
  
  <p><strong>Problem:</strong>
  Why should I create <a href="https://docs.oracle.com/javase/7/docs/api/java/sql/Blob.html" rel="nofollow">Blob</a> instance using <a href="http://docs.jboss.org/hibernate/orm/5.0/javadocs/org/hibernate/Hibernate.html#getLobCreator-org.hibernate.Session-" rel="nofollow">Hibernate.getLobCreator</a> which requires current session? Why it is not possible using [Hibernate.createBlob][3] any more (without accessing current session) ?</p>
  
  <p>In some cases I may need transient domain model with <a href="https://docs.oracle.com/javase/7/docs/api/java/sql/Blob.html" rel="nofollow">Blob</a> field initialized without need to persist it in DB using Dao.</p>
  
  <p>Is it because of (as written in <a href="https://docs.oracle.com/javase/7/docs/api/java/sql/Blob.html" rel="nofollow">Blob</a> JavaDoc) :</p>
  
  <blockquote>
    <p>A Blob object is valid for the duration of the transaction in which is was created.</p>
  </blockquote>
  
  <p>Sorry for asking silly question but I was unable to find satisfying answer.</p>
  
  <p>[3]: <a href="https://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/Hibernate.html#createBlob(java.io.InputStream" rel="nofollow">https://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/Hibernate.html#createBlob(java.io.InputStream</a>, long)</p>