Sleep continuity

I have a relationship between two tables. Many tables contain a clob column. The clob column looks like this: hibernate:

@CollectionOfElements(fetch = EAGER)
@JoinTable(name = NOTE_JOIN_TABLE, joinColumns = @JoinColumn(name = "note"))
@Column(name = "substitution")
@IndexColumn(name = "listIndex", base = 0)
@Lob
private List<String> substitutions;

So basically I can have a note with some permutations, like "foo"and "fizzbuzz". Therefore, in my main table, I could have Note with id 4, and in mine NOTE_JOIN_TABLEI would have two rows, "foo"and "fizzbuzz"that are related to Note.

However, when one of them is inserted into the database , large substitution values ​​are truncated as long as the shortest ones. So, in this case, I would have been "foo", and "fiz"in the database instead of "foo"and "fizzbuzz".

Do you have an idea why this is happening? I checked and confirmed that they are not cropped anywhere in our code, it is clearly sleeping.

+1
source share
2 answers

Many JDBC drivers, early versions of Oracle in particular, have problems inserting LOBs. Have you made sure that the Hibernate request failed with the same parameters that work successfully in your JDBC driver?

0
source

The LOB / CLOB column may not be large enough. Hibernate has some default column sizes for LOB / CLOB, which are relatively small (may depend on db). Anyway, try something like this:

@Lob 
@Column(length=2147483648)

Adjust the length (in bytes) based on your needs.

0
source

Source: https://habr.com/ru/post/1696767/


All Articles