Can't save Entity with byte[] field to DB

When I try to save a JPA entity to my postgres database (schema gets generated by hibernate) I’m getting the following error Caused by: org.postgresql.util.PSQLException: ERROR: column "grenzen" is of type oid but expression is of type bytea.

The field inside the entity is declared as follows: private byte[] grenzen;. I’ve also tried to annotate the field with @Lob and @Type(type=“org.hibernate.type.BinaryType”) but this doesn’t solve the issue.

Does anybody know how this can be fixed without specifying the database schema on my own?

This is what uses for one example entity:

@Column(length = 1000000)
private byte[] image;

I had the same problem a while back. Can confirm that @Lob solved this problem.

As I mentioned before I also tried the @Lob annotation without solving the issue. I spent some time investigating further and found the issue. On my local machine I used a H2 inmemory DB (no problem with storing files) for devloping the app but on heroku I use the heroku-postgres service which spins up a postgres database for me. So I wanted to reproduce the issue on my local machine and therefore I ran a docker container with a postgres image and attached it to my webapp. Without changing anything on my java classes it works just fine. To summarize, the issue is probably on heroku configuring the postgres database. The thread can be closed.