Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

byte[] data in PostgreSQL

I have a spring application that uses MySQL as database.

I want to migrate the application from MySQL to Postgres, and it seems that I can not declare byte[] array:

I have this column:

@Type(type="org.hibernate.type.BinaryType")
private byte[] data.

I get this error:

Caused by: org.postgresql.util.PSQLException: ERROR: type "tinyblob" does not exist

Is there a way to achive this in PostgreSQL?

like image 839
georgiana_e Avatar asked Jul 31 '26 15:07

georgiana_e


1 Answers

In your PostgreSQL DB Table, set the data column datatype to bytea NOT bytea[] and in your POJO class:

@Column(name="name_of_your_column") private byte[] data;

Leave out the @Type(type="org.hibernate.type.BinaryType") annotation.

That should work just fine.

like image 116
MulleOne Avatar answered Aug 03 '26 04:08

MulleOne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!