Hibernate - 如何通过注释设置 sql-type? [英] Hibernate - How to set sql-type by annotation?

查看:18
本文介绍了Hibernate - 如何通过注释设置 sql-type?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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

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

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...

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

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;

推荐答案

你试过了吗

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

这篇关于Hibernate - 如何通过注释设置 sql-type?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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