7

I have a table Campaign_actions which has a column terms with type text. Today I noticed that all text in the column terms are changed to numbers:

screenshot

Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51
  • Looks like OIDs - Hibernate is famous for not being able to properly work with `text` columns. It always (incorrectly) thinks it needs to treat them as "large objects". How was the data stored in that table? –  Nov 19 '18 at 15:26
  • data is stored through java Api (hibernate). – Tengo Chilingarashvili Nov 19 '18 at 15:29
  • 2
    Did you tag that column with `@Lob`? If yes, you should tag with `@String` –  Nov 19 '18 at 15:34
  • Java Api still works correctly, data is taken as text – Tengo Chilingarashvili Nov 19 '18 at 15:37
  • Hibernate stupidly uses the large objects interface which is a total waste for `text` columns (and incorrect to begin with). The correct way to work with `text` columns in JDBC is to use `PreparedStatement.setString()` and `ResultSet.getString()` –  Nov 19 '18 at 15:38
  • Yes i have "@Lob" on property. Does hibernate have "@String " annotation? – Tengo Chilingarashvili Nov 19 '18 at 15:40
  • See [here](https://stackoverflow.com/questions/9158645) or [here](https://stackoverflow.com/questions/28588311) or [here](https://stackoverflow.com/questions/14512771) –  Nov 19 '18 at 15:44
  • @a_horse_with_no_name Thanks! – Tengo Chilingarashvili Nov 19 '18 at 16:05

1 Answers1

2

If you use hibernate annotations in java, you need to specify type of Lob. Example:

    @Lob
    @Type(type = "org.hibernate.type.TextType")
    String largeText;
Alex
  • 316
  • 2
  • 13