3

I have column String post.

I want map this post like a string.

I am using:

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

This code mapping varchar(50).

How can I mapp varchar(max).

I try this code. But I can't compile it.

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

Thank you for your reply.

cagounai
  • 155
  • 2
  • 9

2 Answers2

3

This could be done using code below:

@Column(updatable = true, name="Post", nullable = false, columnDefinition = "varchar(max)")
private String post;

Haven't tried this but it should work based on this columnDefinition.

UPD #1

Basically you could add annotation @Lob OR use very large value for length in @Column.

From documentation:

@Lob indicates that the property should be persisted in a Blob or a Clob depending on the property type: java.sql.Clob, Character[], char[] and java.lang.String will be persisted in a Clob. java.sql.Blob, Byte[], byte[] and serializable type will be persisted in a Blob.

Yuri
  • 1,748
  • 2
  • 23
  • 26
0

Try to write like this:

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

For more info go to link

Abdelhak
  • 8,299
  • 4
  • 22
  • 36