休眠 - 如何通过注释设置SQL类型的? [英] Hibernate - How to set sql-type by annotation?

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

问题描述

我有一个文件为一个byte [] fileContent。由Hibernate和默认Hibernate生成我的MySQL-方案SQL型fileContent的设置为BLOB。

但是,BLOB不是我的文件不够大。我将至少需要MEDIUMBLOM甚至LONGBLOB。

但我怎么可以标注我的领域,这样Hibernate会产生与我作为一个LONGBLOB领域的计划?
我有谷歌搜索当前第2小时,没有得到任何东西...

应该不是这是一个如此简单和常见的任务,它应该被记录的地方??

请帮助失意的程序员!

  @WhatAnnotationCanIUseToForceHibernateToMakeThisALONGBLOB ????
私人字节[] fileContent;


解决方案

你试过

  @Column(columnDefinition =LONGBLOB)
私人字节[] fileContent;

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.

But a BLOB is not big enough for my files. I will need at least a MEDIUMBLOM or even a 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...

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;

解决方案

Have you tried

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

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

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