I need to store a page of html data in a field called ProjectDescription in mySQL database using Spring & JPA 2.1 . I have read this question and all other questions with BLOB tag, but need some clarity on why the fields are saving in a certain manner in my db. I have created the fields in the manner below using both String and byte[] field types.
Method1: Saving data as TEXT (After encoding in Base64 format I save my html data as String using the below method)
@Basic(fetch = FetchType.LAZY)
@Lob
private String projectDescription = "";
Method2: Saving data as binary using BLOB
@Basic(fetch = FetchType.LAZY)
@Lob
@Column(length=5000)
private byte[] projectDescription1 =new byte[0];
My assumptions: I assume that since a page of html data is not very large, TEXT is ok as comapred to BLOB
I tested both and the fields are saved as below in mySQL database
In Method1:
- Type: TEXT
- DisplaySize is constantly 1431655765.
This size doesn't change irrespective of my @Column(length=5000) annotaton.
In Method2
- Type: BLOB
- DisplaySize: -1
Question1: What is the source of this DisplaySize ? This seems quite large in case of TEXT and very small(-1) in case of byte[] field type. Why doesn't @Column length seem to change change the DisplaySize.
Question2: Is it ok to store HTML data as String field type(eventually as TEXT) as opposed to byte[] (eventually as a blob)?
Note: I have read all the questions with BLOB tags and am clear that images/documents need to be saved as BLOB and text as as CLOB/TEXT. However, would like to confirm again for HTML data given how large DisplaySize is allocated in DB for TEXT.
Thanks.