Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
902 views
in Technique[技术] by (71.8m points)

java - JPA - How to set string column to varchar(max) in DDL

With JPA, DDL-generation for the attribute:

@Column
final String someString;

will be someString varchar(255) null

@Column(length = 1337)
final String someString;

will yield someString varchar(1337) null.

But how can I get it to produce someString varchar(max) null?

Is it possible using the length-attribute, or do I need to use the columnDefinition-attribute?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Some months have passed, new knowledge acquired, so I'll answer my own question:

@Lob
@Column
final String someString;

yields the most correct result. With the version of hbm2ddl I'm using, this will be transformed to the type text with SqlServerDialect. Since varchar(max) is the replacement for text in newer versions of SQL Server, hopefully, newer versions of hbm2ddl will yield varchar(max) instead of text for this type of mapping (I'm stuck at a quite dated version of Hibernate at the moment..)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...