I want to store image into database using hibernate and Java. I am using postgres database
I tried bytea
data type to store image and byte[]
data type in hibernate pojo.
I used the following code,
CREATE TABLE photo
(
"photo_name" bytea
)
WITH (OIDS=FALSE);
ALTER TABLE photo OWNER TO postgres;
Hibernate Pojo
public class PhotoEntity {
byte[] name;
public byte[] getName() {
return name;
}
public void setName(byte[] name) {
this.name = name;
}
}
but it gives error at time of mapping.
please give me any reference to do this.