【发布时间】:2012-08-09 09:27:13
【问题描述】:
在我的映射 XML 中我有:
<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>
其中生日是 MYSQL 数据库中的 DATE 类型。
我的 Mapper 界面是这样的:
public interface PatientMapper {
void insertPatient(Patient patient);
Patient getPatientById(Integer id);
Integer getPatientCount();
List<Patient> getPatientsByBirthday(Date bday);
}
我尝试查询具有特定生日的患者:
Calendar cal1 = new GregorianCalendar(1980, 8, 15);
Date bday=cal1.getTime();
List<Patient> plist=mapper.getPatientsByBirthday(bday);
即使有给定日期的记录,这也会返回空列表。
任何提示?
【问题讨论】:
-
在 XML 文件中分享您的 Mapper 接口实现以及结果映射。
标签: java mysql date ibatis mybatis