Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should be storing the image in the table as a BLOB type. Lets assume you have a <code>Person</code> class with the an <code>image</code> of the person stored in the DB. If you want to map this, just add a property in your person POJO that holds the image.</p> <pre><code>@Column(name="image") @Blob private Blob image; </code></pre> <p>When you display it, convert it to a <code>byte[]</code> and show.</p> <pre><code>private byte[] toByteArray(Blob fromImageBlob) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { return toByteArrayImpl(fromImageBlob, baos); } catch (Exception e) { } return null; } private byte[] toByteArrayImpl(Blob fromImageBlob, ByteArrayOutputStream baos) throws SQLException, IOException { byte buf[] = new byte[4000]; int dataSize; InputStream is = fromImageBlob.getBinaryStream(); try { while((dataSize = is.read(buf)) != -1) { baos.write(buf, 0, dataSize); } } finally { if(is != null) { is.close(); } } return baos.toByteArray(); } </code></pre> <p>You can see the below examples to know more about it.</p> <ol> <li><a href="http://i-proving.com/space/Technologies/Hibernate/Blobs+and+Hibernate" rel="nofollow">http://i-proving.com/space/Technologies/Hibernate/Blobs+and+Hibernate</a></li> <li><a href="http://snehaprashant.blogspot.com/2008/08/how-to-store-and-retrieve-blob-object.html" rel="nofollow">http://snehaprashant.blogspot.com/2008/08/how-to-store-and-retrieve-blob-object.html</a></li> <li><a href="http://viralpatel.net/blogs/2011/01/tutorial-save-get-blob-object-spring-3-mvc-hibernate.html" rel="nofollow">http://viralpatel.net/blogs/2011/01/tutorial-save-get-blob-object-spring-3-mvc-hibernate.html</a></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload