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 Bruno Frascino <BF...@smsmt.com> on 2008/10/20 06:25:54 UTC

Multiple Parameters

 Hello,

 I have got:


<resultMap id="basicUserDetails"class="mypack.domain.BasicUserDetails">

 <result property="user" column="user" />

 <result property="employeeId" column="employee_id" />

 <result property="profileLogin" column="PROFILE_LOGIN" />

</resultMap>




<select id="findIt" parameterClass="java.util.Map" resultMap="basicUserDetails">

<![CDATA[

SELECT

o.user,

o.employee_id,

o.profile_login

FROM ATABLE o

WHERE

o.user = #userId#

AND

o.employee_id = #employeeId#

]]>

</select>



then my DAO does:


Map paramM = new HashMap();

paramM.put("userId", userId);

paramM.put("employeeId", employeeId);



users = (List)this.getSqlMapClientTemplate().queryForList("findIt", paramM);



My users list is not null, I don't get any error doing this call but it returns an empty list.
If I hardcode my query then I get my records...

Any help please!?

 Cheers!


Bruno Frascino

________________________________
NOTICE - This communication is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking any action in reliance on, this communication by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient of this communication please delete and destroy all copies and telephone SMS Management & Technology on 9696 0911 immediately. Any views expressed in this Communication are those of the individual sender, except where the sender specifically states them to be the views of SMS Management & Technology. Except as required by law, SMS Management & Technology does not represent, warrant and/or guarantee that the integrity of this communication has been maintained nor that the communication is free from errors, virus, interception or interference.

Re: Multiple Parameters

Posted by Larry Meadors <la...@gmail.com>.
If you're using log4j, set java.sql to DEBUG - that should show you
the sql, the parameters, and the results.

Larry


On Mon, Oct 20, 2008 at 4:56 AM, Bruno Frascino <BF...@smsmt.com> wrote:
>  I know... it seems to be right that's why is so strange!
>  The letter 'o' is an alias for the table.. it is ok.
>  I don't get any exception, but my query doesn't return anything, only when
> I pass only one parameter and hardcode the ohter, it does. And I test this
> query on my database and it works fine.
>  Do you know any configuration that could affect this behaviour of passing
> multiple parameters?
>
>  If I could see the query IBATIS is trying to run, maybe I could have a clue
> of what is happening... how can I see it?
>
>  Thanks and regards!
>
>
>
>
> Bruno Frascino
>
> ________________________________
> From: Vadim [deadmoro3@gmail.com]
> Sent: Monday, 20 October 2008 5:49 PM
> To: user-java@ibatis.apache.org
> Subject: Re: Multiple Parameters
>
> I don't see anything wrong, except 'FROM ATABLE o' in your query, but that's
> probably a typo, because you would have got an exception by now. Also, you
> are searching by ID's - maybe queryForObject is more appropriate in this
> case (just a guess)?
> Have you tried logging database calls? Do the right parameters get passed?
>
> On Mon, Oct 20, 2008 at 7:25 AM, Bruno Frascino <BF...@smsmt.com> wrote:
>>
>>  Hello,
>>
>>  I have got:
>>
>>
>> <resultMap id="basicUserDetails"class="mypack.domain.BasicUserDetails">
>>
>>  <result property="user" column="user" />
>>
>>  <result property="employeeId" column="employee_id" />
>>
>>  <result property="profileLogin" column="PROFILE_LOGIN" />
>>
>> </resultMap>
>>
>>
>> <select id="findIt" parameterClass="java.util.Map"
>> resultMap="basicUserDetails">
>>
>> <![CDATA[
>>
>> SELECT
>>
>> o.user,
>>
>> o.employee_id,
>>
>> o.profile_login
>>
>> FROM ATABLE o
>>
>> WHERE
>>
>> o.user = #userId#
>>
>> AND
>>
>> o.employee_id = #employeeId#
>>
>> ]]>
>>
>> </select>
>>
>>
>> then my DAO does:
>>
>>
>> Map paramM =
>>
>> new HashMap();
>>
>> paramM.put(
>>
>> "userId", userId);
>>
>> paramM.put(
>>
>> "employeeId", employeeId);
>>
>>
>>
>> users = (List)
>>
>> this.getSqlMapClientTemplate().queryForList("findIt", paramM);
>>
>>
>> My users list is not null, I don't get any error doing this call but it
>> returns an empty list.
>> If I hardcode my query then I get my records...
>>
>> Any help please!?
>>
>>  Cheers!
>>
>>
>>
>> Bruno Frascino
>>
>> ________________________________
>> NOTICE - This communication is intended only for the person or entity to
>> which it is addressed and may contain confidential and/or privileged
>> material. Any review, retransmission, dissemination or other use of, or
>> taking any action in reliance on, this communication by persons or entities
>> other than the intended recipient is prohibited. If you are not the intended
>> recipient of this communication please delete and destroy all copies and
>> telephone SMS Management & Technology on 9696 0911 immediately. Any views
>> expressed in this Communication are those of the individual sender, except
>> where the sender specifically states them to be the views of SMS Management
>> & Technology. Except as required by law, SMS Management & Technology does
>> not represent, warrant and/or guarantee that the integrity of this
>> communication has been maintained nor that the communication is free from
>> errors, virus, interception or interference.
>
>
> ________________________________
> NOTICE - This communication is intended only for the person or entity to
> which it is addressed and may contain confidential and/or privileged
> material. Any review, retransmission, dissemination or other use of, or
> taking any action in reliance on, this communication by persons or entities
> other than the intended recipient is prohibited. If you are not the intended
> recipient of this communication please delete and destroy all copies and
> telephone SMS Management & Technology on 9696 0911 immediately. Any views
> expressed in this Communication are those of the individual sender, except
> where the sender specifically states them to be the views of SMS Management
> & Technology. Except as required by law, SMS Management & Technology does
> not represent, warrant and/or guarantee that the integrity of this
> communication has been maintained nor that the communication is free from
> errors, virus, interception or interference.
>

RE: Multiple Parameters

Posted by Bruno Frascino <BF...@smsmt.com>.
 I know... it seems to be right that's why is so strange!
 The letter 'o' is an alias for the table.. it is ok.
 I don't get any exception, but my query doesn't return anything, only when I pass only one parameter and hardcode the ohter, it does. And I test this query on my database and it works fine.
 Do you know any configuration that could affect this behaviour of passing multiple parameters?

 If I could see the query IBATIS is trying to run, maybe I could have a clue of what is happening... how can I see it?

 Thanks and regards!



Bruno Frascino
________________________________
From: Vadim [deadmoro3@gmail.com]
Sent: Monday, 20 October 2008 5:49 PM
To: user-java@ibatis.apache.org
Subject: Re: Multiple Parameters

I don't see anything wrong, except 'FROM ATABLE o' in your query, but that's probably a typo, because you would have got an exception by now. Also, you are searching by ID's - maybe queryForObject is more appropriate in this case (just a guess)?
Have you tried logging database calls? Do the right parameters get passed?

On Mon, Oct 20, 2008 at 7:25 AM, Bruno Frascino <BF...@smsmt.com>> wrote:
 Hello,

 I have got:


<resultMap id="basicUserDetails"class="mypack.domain.BasicUserDetails">

 <result property="user" column="user" />

 <result property="employeeId" column="employee_id" />

 <result property="profileLogin" column="PROFILE_LOGIN" />

</resultMap>


<select id="findIt" parameterClass="java.util.Map" resultMap="basicUserDetails">

<![CDATA[

SELECT

o.user,

o.employee_id,

o.profile_login

FROM ATABLE o

WHERE

o.user = #userId#

AND

o.employee_id = #employeeId#

]]>

</select>


then my DAO does:


Map paramM =

new HashMap();

paramM.put(

"userId", userId);

paramM.put(

"employeeId", employeeId);



users = (List)

this.getSqlMapClientTemplate().queryForList("findIt", paramM);


My users list is not null, I don't get any error doing this call but it returns an empty list.
If I hardcode my query then I get my records...

Any help please!?

 Cheers!



Bruno Frascino

________________________________
NOTICE - This communication is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking any action in reliance on, this communication by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient of this communication please delete and destroy all copies and telephone SMS Management & Technology on 9696 0911 immediately. Any views expressed in this Communication are those of the individual sender, except where the sender specifically states them to be the views of SMS Management & Technology. Except as required by law, SMS Management & Technology does not represent, warrant and/or guarantee that the integrity of this communication has been maintained nor that the communication is free from errors, virus, interception or interference.


________________________________
NOTICE - This communication is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking any action in reliance on, this communication by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient of this communication please delete and destroy all copies and telephone SMS Management & Technology on 9696 0911 immediately. Any views expressed in this Communication are those of the individual sender, except where the sender specifically states them to be the views of SMS Management & Technology. Except as required by law, SMS Management & Technology does not represent, warrant and/or guarantee that the integrity of this communication has been maintained nor that the communication is free from errors, virus, interception or interference.

Re: Multiple Parameters

Posted by Vadim <de...@gmail.com>.
I don't see anything wrong, except 'FROM ATABLE o' in your query, but that's
probably a typo, because you would have got an exception by now. Also, you
are searching by ID's - maybe queryForObject is more appropriate in this
case (just a guess)?
Have you tried logging database calls? Do the right parameters get passed?

On Mon, Oct 20, 2008 at 7:25 AM, Bruno Frascino <BF...@smsmt.com> wrote:

>   Hello,
>
>  I have got:
>
>
> <resultMap id="basicUserDetails"class="mypack.domain.BasicUserDetails">
>
>  <result property="user" column="user" />
>
>  <result property="employeeId" column="employee_id" />
>
>  <result property="profileLogin" column="PROFILE_LOGIN" />
>
> </resultMap>
>
>
> <select id="findIt" parameterClass="java.util.Map" resultMap=
> "basicUserDetails">
>
> <![CDATA[
>
> SELECT
>
> o.user,
>
> o.employee_id,
>
> o.profile_login
>
> FROM ATABLE o
>
> WHERE
>
> o.user = #userId#
>
> AND
>
> o.employee_id = #employeeId#
>
> ]]>
>
> </select>
>
> then my DAO does:
>
>
> Map paramM =
> *new* HashMap();
>
> paramM.put(
> "userId", userId);
>
> paramM.put(
> "employeeId", employeeId);
>
>
>
> users = (List)
> *this*.getSqlMapClientTemplate().queryForList("findIt", paramM);
>
>
> My users list is not null, I don't get any error doing this call but it
> returns an empty list.
> If I hardcode my query then I get my records...
>
> Any help please!?
>
>  Cheers!
>
>
>
> *Bruno Frascino*
>
> ------------------------------
> NOTICE - This communication is intended only for the person or entity to
> which it is addressed and may contain confidential and/or privileged
> material. Any review, retransmission, dissemination or other use of, or
> taking any action in reliance on, this communication by persons or entities
> other than the intended recipient is prohibited. If you are not the intended
> recipient of this communication please delete and destroy all copies and
> telephone SMS Management & Technology on 9696 0911 immediately. Any views
> expressed in this Communication are those of the individual sender, except
> where the sender specifically states them to be the views of SMS Management
> & Technology. Except as required by law, SMS Management & Technology does
> not represent, warrant and/or guarantee that the integrity of this
> communication has been maintained nor that the communication is free from
> errors, virus, interception or interference.
>