I have a one to many relationship between two tables. The many table contains a clob column. The clob column looks like this in 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 may have a Note with some subsitutions, say "foo"
and "fizzbuzz"
. So in my main table I could have a Note with id 4 and in my NOTE_JOIN_TABLE
I would have two rows, "foo"
and "fizzbuzz"
that both have a relationship to the Note.
However, when one of these is inserted into the DB the larger substitution values are cropped to be as long as the shortest. So in this case I would have "foo"
and "fiz"
in the DB instead of "foo"
and "fizzbuzz"
.
Do you have any idea why this is happening? I have checked and confirmed they aren't being cropped anywhere in our code, it's defintely hibernate.
-
LOB/CLOB column may not be large enough. Hibernate has some default column sizes for LOB/CLOB that 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.
SCdF : I don't think this can be it as it's a dynamic cropping based on the largest string in the List and not a static cut-off point.Todd : Ah, I see. Very strange problem. Is the join column of "note" the actual note id or the actual note?SCdF : The 'Note' column is the id of the note from the Note table yeah.From Todd -
Many JDBC drivers, early versions of Oracle in particular, have problems while inserting LOBs. Did you make sure that the query Hibernate fires, with the same parameters bound works successfully in your JDBC driver?
SCdF : It turned out to be a problem with our JDBC driver. The solution (until we can an updated driver) is to disable batching.From binil
0 comments:
Post a Comment