How to read bytea image data from PostgreSQL with JPA?

后端 未结 5 953
离开以前
离开以前 2020-12-31 08:56

I have PostgreSQL database and there is column \'image\' with datatype \'bytea\'. I cannot modify columns or database configurations. JPA annotated POJO contains followign m

5条回答
  •  萌比男神i
    2020-12-31 09:28

    Try to annotate you entity with @Lob

    @Lob
    @Column(name="image")
    private byte[] image;
    

    If you are using hibernate implementation you can add @Type(type="org.hibernate.type.BinaryType") in column too.

    @Lob
    @Column(name="image")
    @Type(type="org.hibernate.type.BinaryType")
    private byte[] image;
    

提交回复
热议问题