Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using CLOBs with JPA

 
Blue Rider Abc Murnau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have a table with a column of type CLOB (I'm using Oracle 10g)
Here I want to store a large set of characters (around 100k).

On the Java side I've created an entity with the JPA annotations.
For the clob element I use the following declaration:

@Column(name="DATA", columnDefinition="CLOB NOT NULL")
@Lob
public String getData() {
return data;
}

In the persistence.xml file I declare that Oracle jdbc driver be used:
<property name="toplink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>

Now, whenever I try to insert a long string the following exception happens:

"java.sql.SQLException: setString can only process strings of less than 32766 chararacters"

I wonder if someone else has had this problem before?

If this were a limitation of the jdbc driver, then how can we work with
clob (lobs) elments transparently using JPA?

thanks
 
Blue Rider Abc Murnau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, I found a solution; I simply updated the oracle jdbc driver
,ojdbc14.jar, to the latest release (10.2.0.1.0 R2).
This has fixed the problem.
Now I can persist transparently CLOBs using JPA.
cool
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed. The newer Oracle JDBC drivers have actually gotten a LOT better.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Blue Rider Abc Murnau"

Please click on the My Profile link above and change your display name to match the JavaRanch Naming Policy of using your real first and last names.

Also note, that users that don't follow the naming policy can NOT win a book.

Thanks

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic