mrblah
mrblah

Reputation: 103577

string value is truncating when saved to the database

I am using hibernate, and my classes property is a string, and my mapping doesn't have any type information, ie:

  <property name="html"  />

I am storing a web page in the html database column, and for some reason the entire page isn't saving, it gets cut off part way.

I outputed the value of the property to console and it does output all the way to the ending </html> tag.

Does hiberate truncate a string value?

the database column is a nvarchar(max) (sql server)

Turns out it was writing the entire string to the database, just copy and pasting from the database editor was truncating the actual text stored in the db column.

Upvotes: 0

Views: 665

Answers (3)

Sapph
Sapph

Reputation: 6208

Try

<property name="Value" type="StringClob" />

Otherwise, Hibernate needs to know the length when dealing with large strings.

Upvotes: 0

user241924
user241924

Reputation: 4438

try

<property name="Value" type="LongVarChar" />

Upvotes: 2

Bozho
Bozho

Reputation: 597204

<property name="html" length="20000" />

I.e. specify the length attribute and set it to a value big enough.

Upvotes: 1

Related Questions