I'm using java with hibernate and would like to know how to insert an image into the mysql database.
I have several information being persisted with hibernate, just missing the image.
I'm using java with hibernate and would like to know how to insert an image into the mysql database.
I have several information being persisted with hibernate, just missing the image.
private byte[] imagem;
...
public byte[] getImagem() {
return this.imagem;
}
public void setImagem(byte[] imagem) {
this.imagem = imagem;
}
And in the mapping file add the property for the image:
<property name="imagem" type="binary">
<column name="imagem" />
</property>
When you save to the database, you programmatically use the setImage method.
For more information, there is a tutorial here: link