Paasing a map as parameterType

2,643 views
Skip to first unread message

YamilBracho

unread,
May 27, 2010, 4:57:26 PM5/27/10
to mybatis-user
Hi
I have this SELECT in my map file

<mapper namespace="MySpace">
<select id="findById"
parameterType="java.util.Map"
resultType="com.mycompany.Person">
SELECT "
FROM PersonTable
WHERE nat= = #{citizenship}#
AND id = #{id}#
</select>
</mapper>

In my java code I have

Map<String, String> parameters = new HashMap<String, String>(2);
parameters.put("citizenship", "French");
parameters.put("iod", "123456");
Person = (person) session.selectOne("MySpace.findById", parameters);

I am using PostgreSQL and i am getting this exception:

org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause:
org.postgresql.util.PSQLException: ERROR: operator does not exist:
character varying #
Hint: No operator matches the given name and argument type(s). You
might need to add explicit type casts.
Position: 1072
### The error may involve MySpace.findById-Inline
### The error occurred while setting parameters
### Cause: org.postgresql.util.PSQLException: ERROR: operator does not
exist: character varying #
Hint: No operator matches the given name and argument type(s). You
might need to add explicit type casts.
Position: 1072
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:
8)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
61)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
53)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:
38)
at
com.mls.ean.servicios.ServiciosServlet.getDiputadoByCedula(ServiciosServlet.java:
78)

Any Hint ?

TIA

Larry Meadors

unread,
May 27, 2010, 5:03:01 PM5/27/10
to mybati...@googlegroups.com
Is this a typo in your email or your sql map?

WHERE nat= = #{citizenship}#

The "= ="?

Larry

Larry Meadors

unread,
May 27, 2010, 5:03:31 PM5/27/10
to mybati...@googlegroups.com
Also, it's just #{}, not #{}#.

YamilBracho

unread,
May 27, 2010, 5:06:07 PM5/27/10
to mybatis-user
My Mistake!!!!!!

I wrote "#{citizenship}#" instead of "#{citizenship}"

Maybe my glasses are not working properly or I really need a
vacation...!

Thanks

Larry Meadors

unread,
May 27, 2010, 5:12:22 PM5/27/10
to mybati...@googlegroups.com
I vote for the vacation. :)

YamilBracho

unread,
May 27, 2010, 5:24:19 PM5/27/10
to mybatis-user
Thanks Larry
I will change my glasses and of course take a vacation...!
Reply all
Reply to author
Forward
0 new messages