wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Using CLOBs with JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Using CLOBs with JPA" Watch "Using CLOBs with JPA" New topic
Author

Using CLOBs with JPA

Blue Rider Abc Murnau
Greenhorn

Joined: Aug 02, 2006
Posts: 4
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

Joined: Aug 02, 2006
Posts: 4
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

Joined: Jul 14, 2005
Posts: 304
Indeed. The newer Oracle JDBC drivers have actually gotten a LOT better.


-Mike
Pro JPA 2: Mastering the Java Persistence API
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

"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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using CLOBs with JPA
 
Similar Threads
How to store & retrieve a video file from database?
Mapping String To CLOB datatype using WSAD 4.0
unable to update CLOB data using Commons DBCP connection.
Convert large string to Clob
Blob Clob