title: How to insert uploaded image from p:fileUpload as BLOB in MySQL?
body: <p>How to insert uploaded image from p:fileUpload as BLOB in MySQL?</p>
  
  <pre><code>@Lob
  @Column(name = "photo")
  private byte[] photo;
  </code></pre>
  
  <p>And in XHTML page, I write <a href="http://www.primefaces.org/showcase/ui/file/upload/single.xhtml" rel="nofollow">this</a>:</p>
  
  <pre><code>&lt;p:inputText value="#{condidat.condidat.photo}" &gt;
  &lt;p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"   
      allowTypes="*.jpg;*.png;*.gif;" description="Images"/&gt;                       
  &lt;/p:inputText&gt;
  </code></pre>
  
  <p>How can I retreive the value of uploaded file as <code>byte[]</code>?</p>