• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Using CLOBs with JPA

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed. The newer Oracle JDBC drivers have actually gotten a LOT better.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic