Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java hibernate:如何将列varchar设置为max?_Java_Mysql_Hibernate - Fatal编程技术网

Java hibernate:如何将列varchar设置为max?

Java hibernate:如何将列varchar设置为max?,java,mysql,hibernate,Java,Mysql,Hibernate,我有一列字符串post 我想把这个post映射成一个字符串 我正在使用: @Column(updatable = true, name = "Post", nullable = false, length=50) public String getPost() { return post; } 此代码映射varchar(50) 如何映射varchar(max) 我试试这个代码。但我不能编译它 @Column(updatable = true, name = "P

我有一列
字符串post

我想把这个
post
映射成一个字符串

我正在使用:

@Column(updatable = true, name = "Post", nullable = false, length=50)
    public String getPost() {
        return post;
    }
此代码映射
varchar(50)

如何映射varchar(max)

我试试这个代码。但我不能编译它

@Column(updatable = true, name = "Post", nullable = false, length=max)
    public String getPost() {
        return post;
    }

感谢您的回复。

这可以使用以下代码完成:

@Column(updatable = true, name="Post", nullable = false, columnDefinition = "varchar(max)")
private String post;
还没有尝试过这个,但它应该在此基础上工作

UPD#1 基本上,您可以添加注释
@Lob
,或者在
@Column
中为
长度使用非常大的值

发件人:

@Lob
表示应根据属性类型将属性持久化到Blob或Clob中:
java.sql.Clob
Character[]
char[]
java.lang.String
将持久化到Clob中
java.sql.Blob
Byte[]
Byte[]
和serializable类型将持久保存在Blob中


这可以使用以下代码完成:

@Column(updatable = true, name="Post", nullable = false, columnDefinition = "varchar(max)")
private String post;
还没有尝试过这个,但它应该在此基础上工作

UPD#1 基本上,您可以添加注释
@Lob
,或者在
@Column
中为
长度使用非常大的值

发件人:

@Lob
表示应根据属性类型将属性持久化到Blob或Clob中:
java.sql.Clob
Character[]
char[]
java.lang.String
将持久化到Clob中
java.sql.Blob
Byte[]
Byte[]
和serializable类型将持久保存在Blob中


试着这样写:

 @Column(updatable = true,name="Post",nullable = false,columnDefinition = "varchar(255)")
 public String getPost() {
    return post;
}

欲了解更多信息,请访问尝试这样写:

 @Column(updatable = true,name="Post",nullable = false,columnDefinition = "varchar(255)")
 public String getPost() {
    return post;
}

有关更多信息,请转到

我不认为50是最大值。我不认为50是最大值。我尝试了您的代码,但此代码没有映射我的表。我尝试了您的代码,但此代码没有映射我的表。