user7038002
user7038002

Reputation:

How to set maximum possible length to string column using hibernate

I am using :

@Length(max = 300)
private String data;

for setting the length of variable data. How can I set the maximum possible length?

I am unsure what to Google for.

Thanks for your help.

Edit: or what type of column is best to use for very long string,.

Upvotes: 0

Views: 2823

Answers (1)

108
108

Reputation: 370

If you want to use varchar for your column use this to limit the lenght.

@Column(length = 300)

For 300 characters you should be ok with varchar.

For a very long string you may consider TEXT for the column type.

Upvotes: 5

Related Questions