1

私のマッピング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);

指定された日付のレコードがあっても、これは空のリストを返します。

任意のヒント ?

4

1 に答える 1

1

このようにマッピングxmlを変更します。

 <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>
于 2012-08-09T11:03:28.303 に答える