ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arun m <arun_m...@yahoo.com>
Subject Re: FW: problem with Ibatis returning correct number of rows
Date Wed, 13 Jul 2005 20:45:25 GMT
Let me start with the content of sqlmap.xml file,
 
sqlmap.xml
  <typeAlias alias="FeesInvoice" type="util.FeesInvoiceBean" />
  <resultMap id="getInvoiceViewDetails" class="util.FeesInvoiceBean">
 <result property="invoiceId" column="invoice_id" />   
 <result property="accountId" column="account_id" />   
 <result property="currentInvoice" column="current_invoice" />   
 <result property="invoiceDate" column="invoice_date" />   
 <result property="invoiceDueDate" column="invoice_due_date" />   
 <result property="invoiceYear" column="invoice_year" />      
 <result property="pastDue" column="past_due" />      
 <result property="statusId" column="status_id" />      
   <result property="waiverId" column="waiver_id" />      
   <result property="waiverAmount" column="waiver_amount" />      
  </resultMap>

<statement id="getInvoiceViewDetailsbyAccountId" resultMap="getInvoiceViewDetails">
  select 
    invoice.invoice_id, 
    invoice.account_id, 
    invoice.current_invoice, 
    invoice.invoice_date, 
    invoice.invoice_due_date, 
    invoice.invoice_year,
    invoice.past_due,
    invoice.status_id,
    invoice.waiver_id,
    invoice.waiver_amount
       from
    invoice
       where invoice.account_id = #accountId#   
      
  </statement>
 
The call in java code is 
 
ArrayList invoiceviews = (ArrayList) getSqlMapClientTemplate().queryForList("getInvoiceViewDetailsbyAccountId",
accountId);
 
The log file is as follows
 
[Jul 13,2005 16:32:46] [127.0.0.1 ] ExecuteThread: '44' for queue: 'default' DEBUG sql.PreparedStatement
- {pstm-100022} PreparedStatement:    select      invoice.invoice_id,      invoice.account_id,
     invoice.current_invoice,        invoice.invoice_date,         invoice.invoice_due_date,
     invoice.invoice_year,        invoice.past_due,     invoice.status_id,        invoice.waiver_id,
       invoice.waiver_amount        from     invoice        where invoice.account_id = ? 
           
[Jul 13,2005 16:32:46] [127.0.0.1 ] ExecuteThread: '44' for queue: 'default' DEBUG sql.PreparedStatement
- {pstm-100022} Parameters: [45508]
[Jul 13,2005 16:32:46] [127.0.0.1 ] ExecuteThread: '44' for queue: 'default' DEBUG sql.PreparedStatement
- {pstm-100022} Types: [java.lang.String]
[Jul 13,2005 16:32:46] [127.0.0.1 ] ExecuteThread: '44' for queue: 'default' DEBUG sql.ResultSet
- {rset-100023} ResultSet
[Jul 13,2005 16:32:46] [127.0.0.1 ] ExecuteThread: '44' for queue: 'default' DEBUG sql.ResultSet
- {rset-100023} Header: [invoice_id, account_id, current_invoice, invoice_date, invoice_due_date,
invoice_year, past_due, status_id, waiver_id, waiver_amount]
[Jul 13,2005 16:32:46] [127.0.0.1 ] ExecuteThread: '44' for queue: 'default' DEBUG sql.ResultSet
- {rset-100023} Result: [17339, 45508, Y, 2005-06-28 00:00:00.0, 2005-09-26 00:00:00.0, 2005,
null, 1, null, null]
[Jul 13,2005 16:33:30] [127.0.0.1 ] ExecuteThread: '47' for queue: 'default' DEBUG sql.Connection
- {conn-100024} Connection

when I execute the statement as produced by the ibatis with the parameter value 45508 I get
2 rows. but as shown inthe log file above ibatis itself (last but one  line) only returns
1 row.
I tried to clear our application specific stuff to make this less confusing. Please let me
know if anything is not clear and I will try again.
But I should say that I was able to retrieve more than one row with ibatis in other situations
and the code in that situation is similar to the above. Not sure what I am missing
 
Thanks in advance
Ram

"Yee, Richard K, CTR,, DMDCWEST" <Richard.Yee.ctr@osd.pentagon.mil> wrote:  

-----Original Message-----
From: Yee, Richard K, CTR,, DMDCWEST 
Sent: Wednesday, July 13, 2005 12:40 PM
To: 'user-java@ibatis.apache.org'
Subject: RE: problem with Ibatis returning correct number of rows


Send us the code where you are outputting the information to the log. You might have a bug
in your code.
 
-Richard
 

-----Original Message-----
From: arun m [mailto:arun_m245@yahoo.com] 
Sent: Wednesday, July 13, 2005 12:24 PM
To: user-java@ibatis.apache.org
Subject: problem with Ibatis returning correct number of rows


Hello there
                 we are implementing ibatis. In one scenario, the code is getting only one
row from the oracle database. I looked at the sql statement generated by Ibatis. The sql statement
gets 2 rows from the database where as Ibatis gets only one.
 
Allow me to give the peice of code diong this.
 
1. the map
 
<resultMap id="getDetails" class="XXXXBean">
   <result property="Id" column="id" />      
   <result property="Amount" column="amount" />      
  </resultMap>

  <statement id="getDetailsbyId" resultMap="getDetails">
  select 
        id,
       amount
       from
    table       where id = #Id#   
      
  </statement>
 
The java code used to call this is as follows
 
ArrayList invoiceviews = (ArrayList) getSqlMapClientTemplate().queryForList("getDetailsbyId",
Id);
 
I did not want to be too verbose in the email hence I shortened the code. I can share the
entire code, if anybody is interested. But the size of arraylist returned in the above code
is 1. The log4j log shows that Ibatis generates only one resultset for the query. But if I
execute the same query generated by Ibatis I get 2 rows in oracle db.
 
Has anyone encountered this problem before ?
 
Thanks
Ram.
 
 
 

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




		
---------------------------------
 Start your day with Yahoo! - make it your home page 
Mime
View raw message