I’m trying to insert an HTML blob into our sql-server2005 database. I’ve been using the data-type [text] for the field the blob will eventually live in. I’ve also put a ‘@Lob’ annotation on the field in the domain model. The problem comes in when the HTML blob I’m attempting to store is larger than 65536 characters.
It seems that is the character-limit for a text data type when using the @Lob annotation. Ideally I’d like to keep the whole blob intact rather than chunk it up into multiple rows in the database.
Allow me to clarify
annotation:
@Lob
@Column(length = Integer. MAX_VALUE) //per an answer on stackoverflow
private String htmlBlob;
database side (sql-server-2005):
CREATE TABLE dbo.IndustrySectorTearSheetBlob(
...
htmlBlob text NULL
...
)
Still seeing truncation after 65536 characters…
EDIT: I’ve printed out the contents of all possible strings (only 10 right now) that would be inserted into the Database. Each string seems to contain all characters, judging by the fact that the close html tag is present at the end of the string….
Actually, I think that what you’re looking for is a CLOB field. Quoting Using Advanced Data Types:
In other words, use a VARCHAR(MAX) or a NVARCHAR(MAX) if you need unicode support. About their maximum length:
That should be enough for your HTML.
EDIT: On the Hibernate side, your annotated entity looks fine. On the database side, it should be ok. However, could you try to use VARCHAR(MAX) instead of TEXT (and remove this doubt about TEXT).
By the way, what Hibernate dialect are you using? And what JDBC driver are you using?