I didn't even think of doing this. I'm so accustomed to providing a resultMap that I didn't even think to try a resultClass.
 
I plugged it in but now when I start I see the following exception:

Cause: com.ibatis.sqlmap.client.SqlMapException: Error. Could not set result class. Cause: java.lang.ClassNotFoundException: byte[]



From: "Jeff Butler" <[EMAIL PROTECTED]> [mailto:"Jeff Butler" <[EMAIL PROTECTED]>]
Sent: Friday, September 22, 2006 12:16 PM
To: [email protected]
Subject: Re: Result mapping

Did you try setting resultClass="byte[]"?  I think it might work (no resultMap in this case).  It will work the same as if you set resultClass to some other simple type (like Integer) - I think iBATIS is smart enough to know that these types don't really have properties.
 
So I'm thinking this:
 
<select id="loadDoc" parameterClass="DocumentStore" resultClass="byte[]">
   readtext op_document_store.document #textPointer# 0 #dataLength#
</select>

 
 
Then do this:
 
byte[] doc = (byte[]) queryForObject(...);
 
It would be worth a try...
 
Jeff Butler

 
On 9/22/06, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:
iBatis 2.2.0 (just compiled from source)
Sybase ASE 12.5
 
I'm storing an XML document into a db table. I've defined the column as an IMAGE datatype. Sybase stores these large amounts of data on pages, external to the table.
From the Sybase documentation:
 
Instead of storing potentially large text and image data in the table, Adaptive Server stores it in a special structure. A text pointer (textptr) which points to the page where the data is actually stored is assigned.
 
Retrieving the data is a two step process. You must first get the pointer and the length of the data and then you can retrieve the data. So I'm first performing a select to retrieve the row of data less the IMAGE column. Then in my resultMap, on the IMAGE column, I define a select attribute to perform the load of the data. Everything appears to work correctly. I can step through the code and see everything getting fired correctly and the data being returned in a byte[]. My problem here is the way I have defined my resultMap for the retrieval of the IMAGE data. At first I thought that I would define the resultClass as my object that expected to receive the data, but that is not correct. (I get a ClassCastException because the returned object is not of the expected type to be assigned.) I need to define the resultClass as a byte[] for everything to succeed correctly, but if I define my resultClass as a byte[], then what is the property of the byte[] that will be assigned the result? I can't leave the property attribute off of the Result element as that makes the XML invalid, so how do I get around this?
 
Thanks for the help.
 
Below is my SQL Map:
 
<code>
  <typeAlias alias="DocumentStore" type="com.sybase.cosmos.domain.DocumentStore"/>
 
  <resultMap class="DocumentStore" id="DocumentStoreResult">
    <result column="id" jdbcType="NUMERIC" property="id"/>
    <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
    <result column="order_code" jdbcType="VARCHAR" property="orderCode"/>
    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
    <result column="mod_date" jdbcType="TIMESTAMP" property="modifiedDate" />
    <result column="version" jdbcType="INTEGER" property="version" />
    <result column="{textPointer=text_pointer,dataLength=data_length}" property="bytes" select="DocumentStore.loadDoc"/>
  </resultMap>
 
  <resultMap class="byte[]" id="DocumentStoreDocResult">
    <result column="document" jdbcType="LONGVARCHAR" property="bytes"/>
  </resultMap>
 
  <select id="findByPrimaryKey" resultMap="DocumentStoreResult">
    select
      docStore.id
    , docStore.order_no
    , docStore.order_code
    , docStore.create_date
    , docStore.mod_date
    , docStore.version
    , textptr(document) as text_pointer
    , datalength(document) as data_length
    from
      document_store docStore
    where
      docStore.id = #id:NUMERIC#
  </select>
 
  <!--
    Retrieves the document based upon the text pointer and the length of the data
    The record must first be retrieved to aquire these values.
  -->
  <select id="loadDoc" parameterClass="DocumentStore" resultMap="DocumentStoreDocResult">
    readtext op_document_store.document #textPointer# 0 #dataLength#
  </select>
</code>
 
 
Chris Mathrusse
(925) 236-5553
 

Reply via email to