Joe
Joe

Reputation: 4542

max length to hibernate column

I create table using hibernate through entity.

How to set length of an column in hibernate with maximum length.

for example :

@Column(name="txn_details_id",nullable = false)
private String txnId;

if I use the above it will create with the default size : 255 but i want to create this column with the maximum allowed size.

how do i do this in hibernate?

It would be helpful if some one helps me to set the max length for all the types.

thanks.

Upvotes: 3

Views: 9291

Answers (1)

Prabhakaran Ramaswamy
Prabhakaran Ramaswamy

Reputation: 26084

do like this

size only

@Column(name="txn_details_id",nullable = false,columnDefinition = "varchar(50)")
private String txnId;

Or

size with default value

@Column(name="txn_details_id",nullable = false,columnDefinition = "varchar(50) default 'ACTIVE'")
private String txnId;

Upvotes: 4

Related Questions