Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What data type does ebean map to BYTEA?

I have a Play! 2.0.2 application that needs to store some files in the database. we are using Ebean for our ORM. I believe I need a BYTEA column in my database to store the file, but I'm not sure what data type to use in my model.

Should I be using some kind of Blob? Or just a byte[]? Or is there another data type I should be using? Thanks!

like image 428
Samo Avatar asked Apr 13 '26 01:04

Samo


1 Answers

To create blob with Ebean you need to use byte array with @Lob annotation

@Lob
public byte[] image;

You'll need to convert between File <-> byte array, so maybe it's easier to store files in filesystem? (besides storing files in FS is just cheaper than in DB)

like image 173
biesior Avatar answered Apr 15 '26 14:04

biesior



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!