In my Mapping XML I have :
<select id="getPatientsByBirthday" parameterType="date" resultType="com.axiohelix.nozoki.entity.Patient">
SELECT id AS id,
pharumo_id AS pharumoId,
code AS code,
family_name AS familyName,
first_name AS firstName,
family_name_kana AS familyNameKana,
first_name_kana AS firstNameKana,
gender AS gender,
address AS address,
tel AS tel
FROM tbl_patient
WHERE birthday = #{id}
</select>
where birthday is a DATE type in MYSQL database.
My Mapper interface is like this :
public interface PatientMapper {
void insertPatient(Patient patient);
Patient getPatientById(Integer id);
Integer getPatientCount();
List<Patient> getPatientsByBirthday(Date bday);
}
I tried to query patients with particular birthday as:
Calendar cal1 = new GregorianCalendar(1980, 8, 15);
Date bday=cal1.getTime();
List<Patient> plist=mapper.getPatientsByBirthday(bday);
Even though there are records with the given date,this return empty list.
Anytips ?
Change your mapping xml likes this;
<select id="getPatientsByBirthday" parameterType="java.util.Date" resultType="com.axiohelix.nozoki.entity.Patient">
SELECT id AS id,
pharumo_id AS pharumoId,
code AS code,
family_name AS familyName,
first_name AS firstName,
family_name_kana AS familyNameKana,
first_name_kana AS firstNameKana,
gender AS gender,
address AS address,
tel AS tel
FROM tbl_patient
WHERE birthday = #{date}
</select>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.