I want to save an image to a database using hibernate and Java. I am using postgres database
I tried the bytea
data bytea
to store the image and the 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 an error while displaying.
please give me a link to this.
source share