Paasing a map as parameterType

Visto 2.635 veces
Saltar al primer mensaje no leído

YamilBracho

no leída,
27 may 2010, 16:57:2627/5/10
a 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

no leída,
27 may 2010, 17:03:0127/5/10
a mybati...@googlegroups.com
Is this a typo in your email or your sql map?

WHERE nat= = #{citizenship}#

The "= ="?

Larry

Larry Meadors

no leída,
27 may 2010, 17:03:3127/5/10
a mybati...@googlegroups.com
Also, it's just #{}, not #{}#.

YamilBracho

no leída,
27 may 2010, 17:06:0727/5/10
a 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

no leída,
27 may 2010, 17:12:2227/5/10
a mybati...@googlegroups.com
I vote for the vacation. :)

YamilBracho

no leída,
27 may 2010, 17:24:1927/5/10
a mybatis-user
Thanks Larry
I will change my glasses and of course take a vacation...!
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos