2

Hi I have a table with TEXT datatype. I am using hibernate to fetch/insert data.

My problem is like

  1. What datatype should I use in my entity class object for TEXT type?
  2. How to convert TEXT data to string and vice versa.
  3. Is there any alternative to TEXT datatype? I need to insert a large text(string) to this column.

2 Answers 2

1
  1. Unsure of the question.
  2. Cast string to it? I'm not sure how you have decided to retrieve the data but it should be String s = (String) textdata;
  3. BIG TEXT or Varchar
Sign up to request clarification or add additional context in comments.

2 Comments

Varchar has 255 char limit.I need more. I tried to use it as a string for inserting and retrieving values. No errors are thrown ut not inserting any values into database.
Use big text then, it has a ridiculous size and it is almost the same as entering in text. Big Text is a String so converting shouldn't be needed with the proper sql code, if you would share the code you have currently that isn't working I may be able to see where the problem is.
0

1.What datatype should I use in my entity class object for TEXT type?

Answer

java.lang.String

2.How to convert TEXT data to string and vice versa.

Answer

It is already String no need to convert.

3.Is there any alternative to TEXT datatype? I need to insert a large text(string) to this column.

Answer

You can store up to length 65535


For .hbm.xml file

<property name="property" type="string">
  <column name="column" length="65535" />
</property>

You can generate .java and .hbm.xml through hibernate code generation tool for eclipse


For annotation

@Column(name = "COLUMNNAME", length = 65535)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.