0

I have a byte[] that I am persisting to a Lob as follows:

@Basic(fetch = FetchType.LAZY)
@Column(name = "ABF", length = Integer.MAX_VALUE)
@Lob
private byte[] abf;

Seems simple enough, but when I attempt to store anything sizable in it (more than 4000 characters) I get the following exception when I try to commit:

java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested

None of the files I am attempting to store are anywhere near 32,000 characters. Is there some other gotcha here?

skaffman
  • 398,947
  • 96
  • 818
  • 769
MTR
  • 1,411
  • 4
  • 14
  • 23

4 Answers4

2

See this post.

Nutshell:

<property name="hibernate.connection.SetBigStringTryClob">true</property>
<property name="hibernate.jdbc.batch_size">0</property>

It can also be:

  • Old Oracle JDBC driver (although I think then the limit was 2k)
  • Driver/DB version mismatch
  • Wrong Oracle dialect specified in Hibernate config

For DB stuff it's always helpful to supply driver and DB version info :)

Community
  • 1
  • 1
Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • Hmm... No luck so far with these properties. I'm using Oracle 11g but with 10g dialect since there is no 11g dialect – MTR Nov 11 '11 at 00:32
  • 1
    @MTR Hmm. I mean, I know that's the problem, but I don't recall how to fix it (and I have :/ By the way, why is your length `Integer.MAX_VALUE`? If nothing else, make that a reasonable number; may not fix it, but I'm assuming you don't really mean it, either. – Dave Newton Nov 11 '11 at 00:36
  • I'm beginning to think that perhaps there is a character or something in the file that causes the error. It allows some files to be saved without exception and others throw the error. I'm not yet able to figure out what the difference is. – MTR Nov 11 '11 at 14:47
  • GOT IT! I had to update two libraries: hsqldb.jar (to version 2.2.5) and ojdbc14 to current. Thanks for your help @Dave Newton – MTR Nov 11 '11 at 15:21
  • @MTR Sweet; yeah, the Oracle drivers are pretty version-sensitive when it comes to a few things. I'm not sure I actually answered the question though, just pointed. Consider answering your own question with details and accepting that instead. – Dave Newton Nov 11 '11 at 15:31
1

Sometimes it helps to do things in that order:

  • insert the new entity with an empty lob;
  • commit;
  • populate the lob on the newly created entity;
  • update and commit.
Andrei Petrenko
  • 3,922
  • 3
  • 31
  • 53
1

i just updated the oracle driver and it worked fine.

it is mainly due to the oracle driver mismatch.

If you have right version of jdbc driver corresponding to you oracle version, it should not be an issue.

user1139928
  • 131
  • 1
  • 1
  • 6
0

@Dave Newton set me on the right path. The answer involved a few things. As Dave pointed out, I added these lines to hibernate.cfg.xml:

<property name="hibernate.connection.SetBigStringTryClob">true</property>
<property name="hibernate.jdbc.batch_size">0</property>

I was previously using hsqldb-2.0.0.jar. I updated this to the current version (hsqldb-2.2.5.jar). I think this was the main culprit, and I swear I've noticed a database performance increase since doing this.

I also updated to the current version of ojdbc14.jar (10.2.0.5). I was previously on some older version, but I don't know exactly which one. It should be noted that even after updating to version 10.2.0.5 the problem did not go away. It wasn't until I updated the hsqldb.jar version that the problem was resolved.

MTR
  • 1,411
  • 4
  • 14
  • 23