title: Hibernate 4.2.2 create blob from unknown-length input stream
body: <p>Hi i want to create a blob in hibernate from an inputstream, but i don't know the length of the stream.</p>
  
  <pre><code>Hibernate.getLobCreator(sessionFactory.getCurrentSession()).createBlob(stream, length)
  </code></pre>
  
  <p>how can i crate a blob without knowing the length of the stream?</p>
  
  <p>EDIT1</p>
  
  <p>in older hibernate versions it was possible</p>
  
  <p><a href="http://viralpatel.net/blogs/tutorial-save-get-blob-object-spring-3-mvc-hibernate/" rel="noreferrer">http://viralpatel.net/blogs/tutorial-save-get-blob-object-spring-3-mvc-hibernate/</a></p>
  
  <p>Blob blob = Hibernate.createBlob(file.getInputStream());</p>
  
  <p>EDIT2</p>
  
  <p>ok but it had an buggy implementation</p>
  
  <p>return new SerializableBlob( new BlobImpl( stream, stream.available() ) );</p>
  
  <p>stream.available isn't the real size</p>
  
  <p>EDIT 3 </p>
  
  <p>i tried</p>
  
  <pre><code>session.doWork(new Work() {
              @Override
              public void execute(Connection conn) throws SQLException {
              LargeObjectManager lobj = ((org.postgresql.PGConnection) conn).getLargeObjectAPI();
  </code></pre>
  
  <p>but conn is just a NewProxyConnection from c3p0. </p>