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>
<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
[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
Ram
"Yee, Richard K, CTR,, DMDCWEST" <[EMAIL PROTECTED]> wrote:
-----Original Message-----
From: Yee, Richard K, CTR,, DMDCWEST
Sent: Wednesday, July 13, 2005 12:40 PM
To: '[email protected]'
Subject: RE: problem with Ibatis returning correct number of rowsSend 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:[EMAIL PROTECTED]
Sent: Wednesday, July 13, 2005 12:24 PM
To: [email protected]
Subject: problem with Ibatis returning correct number of rowsHello therewe 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 followsArrayList 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 ?ThanksRam.__________________________________________________
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
