问题
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!
回答1:
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)
来源:https://stackoverflow.com/questions/11569838/what-data-type-does-ebean-map-to-bytea