java Hibernate - 如何通过注释设置 sql 类型?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7081044/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 18:33:24  来源:igfitidea点击:

Hibernate - How to set sql-type by annotation?

javahibernateannotationsblob

提问by user829237

I have a file as a byte[] fileContent. My mySql-scheme is generated by Hibernate and by default hibernate sets the sql-type of fileContent to BLOB.

我有一个文件作为字节 [] 文件内容。我的 mySql-scheme 是由 Hibernate 生成的,默认情况下,hibernate 将 fileContent 的 sql-type 设置为 BLOB。

But a BLOB is not big enough for my files. I will need at least a MEDIUMBLOM or even a LONGBLOB.

但是 BLOB 对我的文件来说不够大。我至少需要一个 MEDIUMBLOM 甚至一个 LONGBLOB。

But how can i annotate my field so that Hibernate will generate the scheme with my field as a LONGBLOB? I have search google for 2 hours now without getting anything...

但是如何注释我的字段,以便 Hibernate 将我的字段作为 LONGBLOB 生成方案?我现在已经在谷歌上搜索了 2 个小时没有得到任何东西......

Shouldn't this be a so simple and common task that it should be documented somewhere??

这不应该是一个如此简单和常见的任务,应该在某处记录吗?

Please help a frustrated programmer!!

请帮助一个沮丧的程序员!

@WhatAnnotationCanIUseToForceHibernateToMakeThisALONGBLOB????
private byte[] fileContent;

回答by axtavt

Have you tried

你有没有尝试过

@Column(columnDefinition = "LONGBLOB")
private byte[] fileContent;