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 leo71 <on...@gmail.com> on 2008/09/05 15:43:41 UTC

Help with parametermap ( List in a Map )

Hi
I am trying to set a list in a map as the parameterMap 

See the code below
 
 <select id="getInfo" parameterClass="java.util.HashMap"
resultMap="someResult">
	SELECT 
		firstName AS firstName,
		lastName AS lastName
		FROM employee
	WHERE employee_dept_id = #employeeDeptId# 
	 and class_id in 
	<iterate property="classId" open="(" close=")" conjunction=",">
         #[],javaType=java.lang.Integer,jdbcType=INTEGER# 
	</iterate> 
	
  </select>	
  
  Java part is
  List classId= new ArrayList();
  classId.add(new Integer(0));
  classId.add(new Integer(1));
  classId.add(new Integer(2));
  
  HashMap parameters = new HashMap();
  parameters.put("employeeDeptId", "ABC123");
  parameters.put("classId", classId);
  
  List classifiedEmployees =
getTemplate().queryForList("getClassifiedEmployees",parameters);
  
  It gives me the following
  --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
list from JavaBean. Cause java.lang.NumberFormatException: For input string:
""
  
  
I tried changing it  like this
	<iterate property="classId" open="(" close=")" conjunction=",">
         #classId[],javaType=java.lang.Integer,jdbcType=INTEGER# 
	</iterate> 	
	
	That solves the exception problem but does not return any rows even though
it should return 2 rows
	
Please let me know if any one can help me with this. I spend a lot of time
but did not find good documentation on how parameter maps 
should be created with lists inside maps. I tried to debug into the ibatis
code but am not getting anywhere.
-- 
View this message in context: http://www.nabble.com/Help-with-parametermap-%28-List-in-a-Map-%29-tp19331531p19331531.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Help with parametermap ( List in a Map )

Posted by Jeff Butler <je...@gmail.com>.
The second form looks correct to me (the first form is definitely not
right).  Suggest you turn on logging and see what's being generated.

Jeff Butler

On Fri, Sep 5, 2008 at 8:43 AM, leo71 <on...@gmail.com> wrote:

>
> Hi
> I am trying to set a list in a map as the parameterMap
>
> See the code below
>
>  <select id="getInfo" parameterClass="java.util.HashMap"
> resultMap="someResult">
>        SELECT
>                firstName AS firstName,
>                lastName AS lastName
>                FROM employee
>        WHERE employee_dept_id = #employeeDeptId#
>         and class_id in
>        <iterate property="classId" open="(" close=")" conjunction=",">
>         #[],javaType=java.lang.Integer,jdbcType=INTEGER#
>        </iterate>
>
>  </select>
>
>  Java part is
>  List classId= new ArrayList();
>  classId.add(new Integer(0));
>  classId.add(new Integer(1));
>  classId.add(new Integer(2));
>
>  HashMap parameters = new HashMap();
>  parameters.put("employeeDeptId", "ABC123");
>  parameters.put("classId", classId);
>
>  List classifiedEmployees =
> getTemplate().queryForList("getClassifiedEmployees",parameters);
>
>  It gives me the following
>  --- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal
> list from JavaBean. Cause java.lang.NumberFormatException: For input
> string:
> ""
>
>
> I tried changing it  like this
>        <iterate property="classId" open="(" close=")" conjunction=",">
>         #classId[],javaType=java.lang.Integer,jdbcType=INTEGER#
>        </iterate>
>
>        That solves the exception problem but does not return any rows even
> though
> it should return 2 rows
>
> Please let me know if any one can help me with this. I spend a lot of time
> but did not find good documentation on how parameter maps
> should be created with lists inside maps. I tried to debug into the ibatis
> code but am not getting anywhere.
> --
> View this message in context:
> http://www.nabble.com/Help-with-parametermap-%28-List-in-a-Map-%29-tp19331531p19331531.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>