I have PostgreSQL database and there is column 'image' with datatype 'bytea'. I cannot modify columns or database configurations. JPA annotated POJO contains followign mapping
@Column(name="image")
private byte[] image;
The returned data is in following format (this is just a sample)
WF5ClN6RlpLZ0hJTUdNQ1FJWmkwcFVGSUdNQ0lDWUE5TUEvanRFeElwK2x0M2tBQUFBQVNVVk9SSzVDWUlJPQo=
When I write this data to file (.jpeg) photo viewer says "this is corrupted file". I also understand that actual image byte data looks different from above sample. I read some blogs which mentioned that PostgreSQL applies hexadecimal conversion to bytea data. How to restore it to original data with or without JPA ?
Database - PostgresSQL Version 9.5.1
Driver
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1205-jdbc41</version>
</dependency>
@Lobannotation; see this related question). How did you get that base64 representation exactly? Are you sure that's not something, that's outputted (and possibly transformed) by a view-related service? (Please try to debug the@Entityto see, what's exactly get back to theimageproperty & what do you set to that property before saving).