ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject RE: Result mapping
Date Fri, 22 Sep 2006 19:27:04 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META boundary="----=_Part_33280_26890769.1158952554317" alternative; multipart 
<META http-equiv=Content-Type content="text/html; charset=us-ascii" 
Content-Type: ------="_Part_33280_26890769.1158952554317" inline 
Content-Disposition: html; text quoted-printable Content-Transfer-Encoding:>
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<DIV dir=ltr align=left><SPAN class=990492119-22092006><FONT color=#0000ff

size=2>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=990492119-22092006><FONT color=#0000ff

<DIV dir=ltr align=left><SPAN class=990492119-22092006><FONT color=#0000ff

size=2>I plugged it in but now when I start I see the following 
<DIV dir=ltr align=left><SPAN class=990492119-22092006><FONT color=#ff0000

<P>Cause: </FONT><U><FONT color=#000080 
size=2>com.ibatis.sqlmap.client.SqlMapException</U></FONT><FONT color=#ff0000

size=2>: Error. Could not set result class. Cause: </FONT><U><FONT color=#000080

size=2>java.lang.ClassNotFoundException</U></FONT><FONT color=#ff0000 size=2>:

<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> "Jeff Butler" 
&lt;jeffgbutler@gmail.com&gt; [mailto:"Jeff Butler" 
&lt;jeffgbutler@gmail.com&gt;] <BR><B>Sent:</B> Friday, September
22, 2006 12:16 
PM<BR><B>To:</B> user-java@ibatis.apache.org<BR><B>Subject:</B>
Re: Result 
<DIV>Did you try setting resultClass="byte[]"?&nbsp; I think it might work (no 
resultMap in this case).&nbsp; 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. </DIV>
<DIV>So I'm thinking this:</DIV>
<DIV><FONT size=2>&lt;select id="loadDoc" parameterClass="DocumentStore" 
<STRONG>resultClass="byte[]"</STRONG>&gt;<BR>&nbsp;&nbsp; readtext

op_document_store.document #textPointer# 0 
<DIV>Then do this:</DIV>
<DIV>byte[] doc = (byte[]) queryForObject(...);</DIV>
<DIV>It would be worth a try...</DIV>
<DIV>Jeff Butler<BR><BR>&nbsp;</DIV>
<DIV><SPAN class=gmail_quote>On 9/22/06, <B class=gmail_sendername><A


</A>&gt; wrote:</SPAN> 
<BLOCKQUOTE class=gmail_quote 
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
  <DIV><SPAN><FONT size=2>iBatis 2.2.0 (just compiled from 
  <DIV><SPAN><FONT size=2>Sybase ASE 12.5</FONT></SPAN></DIV>
  <DIV><SPAN><FONT size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN><FONT size=2>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. </FONT></SPAN></DIV>
  <DIV><SPAN><FONT size=2>From the Sybase documentation:</FONT></SPAN></DIV>
  <DIV><SPAN><FONT size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN>Instead of storing potentially large text and image data in the 
  table, Adaptive Server stores it in a special structure. A text pointer 
  (<B>textptr</B>) which points to the page where the data is actually stored
  assigned. </SPAN></DIV>
  <DIV><SPAN><FONT size=2>Retrieving the data is a two step process. You
  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? 
  <DIV><SPAN><FONT size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN><FONT size=2>Thanks for the help.</FONT></SPAN></DIV>
  <DIV><SPAN><FONT size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN><FONT size=2>Below is my SQL Map:</FONT></SPAN></DIV>
  <DIV><SPAN><FONT size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN><FONT size=2>&lt;code&gt;<BR>&nbsp; &lt;typeAlias

  <DIV><SPAN><FONT size=2>&nbsp; &lt;resultMap class="DocumentStore"

  id="DocumentStoreResult"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;result
  jdbcType="NUMERIC" property="id"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;result

  column="order_no" jdbcType="VARCHAR" property="orderNo"/&gt; 
  <BR>&nbsp;&nbsp;&nbsp; &lt;result column="order_code" jdbcType="VARCHAR"

  property="orderCode"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;result 
  column="create_date" jdbcType="TIMESTAMP" property="createDate" /&gt; 
  <BR>&nbsp;&nbsp;&nbsp; &lt;result column="mod_date" jdbcType="TIMESTAMP"

  property="modifiedDate" /&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;result

  column="version" jdbcType="INTEGER" property="version" /&gt; 
  <BR>&nbsp;&nbsp;&nbsp; &lt;result 
  column="{textPointer=text_pointer,dataLength=data_length}" property="bytes" 
  select="DocumentStore.loadDoc"/&gt;<BR>&nbsp; &lt;/resultMap&gt;<BR>&nbsp;

  <BR>&nbsp; &lt;resultMap class="byte[]" id="DocumentStoreDocResult"&gt;

  <BR>&nbsp;&nbsp;&nbsp; &lt;result column="document" jdbcType="LONGVARCHAR"

  property="bytes"/&gt;<BR>&nbsp; &lt;/resultMap&gt;<BR>&nbsp;
  &lt;select id="findByPrimaryKey" resultMap="DocumentStoreResult"&gt; 
  <BR>&nbsp;&nbsp;&nbsp; select <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

  docStore.id<BR>&nbsp;&nbsp;&nbsp; , docStore.order_no<BR>&nbsp;&nbsp;&nbsp;
  docStore.order_code<BR>&nbsp;&nbsp;&nbsp; , 
  docStore.create_date<BR>&nbsp;&nbsp;&nbsp; , 
  docStore.mod_date<BR>&nbsp;&nbsp;&nbsp; , 
  docStore.version<BR>&nbsp;&nbsp;&nbsp; , textptr(document) as 
  text_pointer<BR>&nbsp;&nbsp;&nbsp; , datalength(document) as 
  data_length<BR>&nbsp;&nbsp;&nbsp; from<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

  document_store docStore<BR>&nbsp;&nbsp;&nbsp; where 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; docStore.id = #id:NUMERIC#<BR>&nbsp;

  &lt;/select&gt;<BR>&nbsp; <BR>&nbsp; &lt;!-- <BR>&nbsp;&nbsp;&nbsp;
  the document based upon the text pointer and the length of the data 
  <BR>&nbsp;&nbsp;&nbsp; The record must first be retrieved to aquire these

  values. <BR>&nbsp; --&gt;<BR>&nbsp; &lt;select id="loadDoc"

  resultMap="DocumentStoreDocResult"&gt;<BR>&nbsp;&nbsp;&nbsp; readtext

  op_document_store.document #textPointer# 0 #dataLength# <BR>&nbsp; 
  <DIV><SPAN><FONT size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><FONT size=2></FONT>&nbsp;</DIV>
  <DIV align=left><FONT size=2>Chris Mathrusse</FONT></DIV>
  <DIV align=left><FONT size=2><A 
  onclick="return top.js.OpenExtLink(window,event,this)" 
  <DIV align=left><FONT size=2>(925) 236-5553</FONT></DIV>

View raw message