File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Blob and Clob in iBatis Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Blob and Clob in iBatis" Watch "Blob and Clob in iBatis" New topic

Blob and Clob in iBatis

Kriti Garg
Ranch Hand

Joined: Sep 13, 2004
Posts: 50
Hi ,
How can we use Blob and Clob in iBATIS OR Mapping.

Clinton Begin

Joined: Nov 08, 2006
Posts: 21
My personal feeling is that if the data type is BLOB or CLOB, it's probably too big to be keeping around in memory anyway. In general, with these types, you want to either stream them directly to the browser, or stream them to a file on disk (good for caching) and then let the browser download the file directly. Those are the appproaches I recommend, and for those, you should use straight JDBC (not iBATIS, Hibernate or any other tool).

With that little disclaimer out of the way....

In some cases, it makes sense to map small BLOBs (avatar images) and CLOBs (text that blows the 255 or 65k char limit of some DBs). CLOB is the most common case, and iBATIS can do that simply by specifying a String Java type and a CLOB or LONGVARCHAR JDBC type. For BLOB, you must map a Java property of type byte[] (byte array) to a JDBC type of BLOB or LONGVARBINARY.

I recommend using iBATIS 2.3.

Note to Oracle users: for BLOB and CLOB you must use Oracle 10g drivers, as previous to that version they did not support the standard JDBC *LOB interface. The 10g drivers can be used with older Oracle databases, or at least with 9i.

I agree. Here's the link:
subject: Blob and Clob in iBatis
It's not a secret anymore!