You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Sumanta Ghosh <su...@tcs.com> on 2006/08/11 14:41:47 UTC

IBATIS not working

Hi,

I have just started using IBATIS. We have one sqlMap as following
<sqlMap namespace="Initiator">

  <resultMap id="paymentResult"
class="com.pdl.cas.initiator.domain.Payment">
    <result property="initiatorId" column="initiatorId" columnIndex="1"/>
    <result property="year" column="year" columnIndex="2"/>
    <result property="month" column="month" columnIndex="3"/>
    <result property="gross" column="gross" columnIndex="4"/>
    <result property="tds" column="tds" columnIndex="5"/>
    <result property="net" column="net" columnIndex="6"/>
    <result property="txnSeqNo" column="txnSeqNo" columnIndex="7"/>
    <result property="createdBy" column="createdBy" columnIndex="8"/>
    <result property="createdOn" column="createdOn" columnIndex="9"/>
    <result property="modifiedBy" column="modifiedBy" columnIndex="10"/>
    <result property="modifiedOn" column="modifiedOn" columnIndex="11"/>
    <result property="verNo" column="verNo" columnIndex="12"/>
  </resultMap>
  
  <select id="loadPayment" resultMap="paymentResult"
parameterClass="com.pdl.cas.initiator.domain.Payment">
    SELECT
initiatorId,year,month,gross,tds,net,txnSeqNo,createdBy,createdOn,modifiedBy,modifiedOn,verNo
    FROM Payment WHERE initiatorId=#initiatorId# AND year=#year# AND
month=#month# 
  </select>	

</sqlMap>
 - then I am calling
sqlMap.getQueryForObject("loadPayment",payment,payment);
where payment is an instance of class com.pdl.cas.initiator.domain.Payment

The problem is even if database contain one row with the value specified in
payment instance - it is not getting populated.
Please let me know if I am doing something worng
[NOTE: I am using IBATIS from spring (i.e. using springs
sqlMapClientTemplate)

-- 
View this message in context: http://www.nabble.com/IBATIS-not-working-tf2090424.html#a5761544
Sent from the iBATIS - User - Java forum at Nabble.com.


Re: IBATIS not working

Posted by Sumanta Ghosh <su...@tcs.com>.
Yes in fact it is returning null - though from my sql prompt using the same
where clause I am getting data.
-- 
View this message in context: http://www.nabble.com/IBATIS-not-working-tf2090424.html#a5762142
Sent from the iBATIS - User - Java forum at Nabble.com.


Re: IBATIS not working

Posted by Gwyn Evans <gw...@gmail.com>.
You're not the first & you won't be the last...

Maybe iBATIS should just flag a warning when it discovers a CHAR
column, with the only way to disable the warning being via a setting
mentioned only in a section of the doc warning about the need to pad
CHAR columns... :-)

/Gwyn

On 11/08/06, Sumanta Ghosh <su...@tcs.com> wrote:
>
> Hello Everybody,
> The problem is solved - it was a silly problem - the database column was
> CHAR(10) not VARCHAR and I was giving input as 'ABC' as a result it was not
> giving any result. Why I was confused becuse the sql client I am using
> (PlSql developer from Allround) is smart enough to automatically change my
> query to return result.
> Anyway thanks to all of you, and at the same time sorry for such a silly
> problem.
> --
> View this message in context: http://www.nabble.com/IBATIS-not-working-tf2090424.html#a5764367
> Sent from the iBATIS - User - Java forum at Nabble.com.
>
>


-- 
Download Wicket 1.2.1 now! - http://wicketframework.org

RE: IBATIS not working

Posted by Sumanta Ghosh <su...@tcs.com>.
Hello Everybody,
The problem is solved - it was a silly problem - the database column was
CHAR(10) not VARCHAR and I was giving input as 'ABC' as a result it was not
giving any result. Why I was confused becuse the sql client I am using
(PlSql developer from Allround) is smart enough to automatically change my
query to return result.
Anyway thanks to all of you, and at the same time sorry for such a silly
problem.
-- 
View this message in context: http://www.nabble.com/IBATIS-not-working-tf2090424.html#a5764367
Sent from the iBATIS - User - Java forum at Nabble.com.


Re: IBATIS not working

Posted by Gwyn Evans <gw...@gmail.com>.
Might be worth posting the table description, just to see if that
suggests anything.

/Gwyn

On 11/08/06, Sumanta Ghosh <su...@tcs.com> wrote:
>
> From straight client (sql plus editor) I am getting the row (using same login
> userid and password) - jdbc I have'nt checked yet.
>
> --
> View this message in context: http://www.nabble.com/IBATIS-not-working-tf2090424.html#a5762356
> Sent from the iBATIS - User - Java forum at Nabble.com.
>
>


-- 
Download Wicket 1.2.1 now! - http://wicketframework.org

RE: IBATIS not working

Posted by Sumanta Ghosh <su...@tcs.com>.
>From straight client (sql plus editor) I am getting the row (using same login
userid and password) - jdbc I have'nt checked yet.

-- 
View this message in context: http://www.nabble.com/IBATIS-not-working-tf2090424.html#a5762356
Sent from the iBATIS - User - Java forum at Nabble.com.


Re: IBATIS not working

Posted by Ted Schrader <te...@gmail.com>.
Is queryForObject() returning null or the instance?

I mention this because the Javadoc says it will return "The single
result object as supplied by the resultObject parameter, populated
with the result set data, or null if no result was found".

Forgive the suggestion, but if it's null, your query isn't finding any
results and therefore your payment object wouldn't be further
populated.

Just something to double-check.

Ted

RE: IBATIS not working

Posted by Sumanta Ghosh <su...@tcs.com>.
Do I need to use that? because from the log file it is evident IBATIS is
identifying the query, the parameters etc. Just check the log trace below

[java.sql.PreparedStatement] - {pstm-100001} PreparedStatement:      SELECT
initiatorId,year,month,gross,tds,net,txnSeqNo,createdBy,createdOn,modifiedBy,modifiedOn,verNo    
FROM Payment WHERE initiatorId=? AND year=? AND month=?    
2006-08-11 18:15:02,726 DEBUG [java.sql.PreparedStatement] - {pstm-100001}
Parameters: [ABC, 2006, 3]
2006-08-11 18:15:02,726 DEBUG [java.sql.PreparedStatement] - {pstm-100001}
Types: [java.lang.String, java.lang.Integer, java.lang.Integer]
2006-08-11 18:15:02,736 DEBUG [java.sql.ResultSet] - {rset-100002} ResultSet

the problem is finally the payment instance is not getting populated 
-- 
View this message in context: http://www.nabble.com/IBATIS-not-working-tf2090424.html#a5761794
Sent from the iBATIS - User - Java forum at Nabble.com.