mark

From http://code.google.com/p/mybatis/wiki/HowToSelectMultipleParams

 

Solution

  1. Add the @Param("name") to your Mapper.java
  2. Change the parameterType in Mapper.xml to "map"

1. Add the @Param("name") to your Mapper.java

UserMapper.java:

import
 org
.
apache
.
ibatis
.
annotations
.
Param
;


public
 
interface
 
UserMapper
{

   
User
 selectUser
(
@Param
(
"username"
)
 
String
 usrename
,
 
@Param
(
"hashedPassword"
)
 
String
 hashedPassword
);


}

2. Change the parameterType in Mapper.xml to "map"

UserMapper.xml:

<select
 
id
=
”selectUser”
 
parameterType
=
”map”
 
resultType
=
”User”
>

  select id, username, hashedPassword
  from some_table
  where usrename = #{username}
  and hashedPassword = #{hashedPassword}

</sql>

你可能感兴趣的:(mark)