ebean映射到BYTEA的数据类型是什么? [英] What data type does ebean map to BYTEA?

查看:162
本文介绍了ebean映射到BYTEA的数据类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个玩! 2.0.2应用程序需要在数据库中存储一些文件。我们正在使用Ebean作为我们的ORM。我相信我需要在我的数据库BYTEA列来存储文件,但我不知道在我的模型中使用什么数据类型。



我应该使用一些类型 Blob ?或者只是一个 byte [] ?还是有另一种数据类型,我应该使用?谢谢!

解决方案

使用Ebean创建blob,您需要使用带有@Lob注释的字节数组

  @Lob 
public byte [] image;

您需要在File<>字节数组之间转换,所以也许更容易文件系统中的文件? (除了在FS中存储文件只是比在DB中便宜)


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!

解决方案

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)

这篇关于ebean映射到BYTEA的数据类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆