What data type does ebean map to BYTEA?

蓝咒 提交于 2020-01-14 14:49:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!