Commit d99c021c authored by Deep Dey's avatar Deep Dey

fix: force typecasting of null by RowMapper

parent c9ca230b
package com.example.LaMartin.admission.mapper; package com.example.LaMartin.admission.mapper;
import com.example.LaMartin.admission.model.AdmissionFormData; import com.example.LaMartin.admission.model.AdmissionFormData;
import com.example.LaMartin.common.utils.RowMapperUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -16,51 +17,54 @@ public class AdmissionFormMapper implements RowMapper<AdmissionFormData> { ...@@ -16,51 +17,54 @@ public class AdmissionFormMapper implements RowMapper<AdmissionFormData> {
AdmissionFormData formData = new AdmissionFormData(); AdmissionFormData formData = new AdmissionFormData();
formData.setId(rs.getLong("id")); formData.setId(rs.getLong("id"));
formData.setSchool(rs.getString("school")); formData.setSchool(RowMapperUtil.getString(rs, "school"));
formData.setCategory(rs.getString("category")); formData.setCategory(RowMapperUtil.getString(rs, "category"));
formData.setFullName(rs.getString("full_name")); formData.setFullName(RowMapperUtil.getString(rs, "full_name"));
formData.setAdmissionClass(rs.getString("admission_class")); formData.setAdmissionClass(RowMapperUtil.getString(rs, "admission_class"));
formData.setDateOfBirth(rs.getString("date_of_birth")); formData.setDateOfBirth(RowMapperUtil.getString(rs, "date_of_birth"));
formData.setNationality(rs.getString("nationality")); formData.setNationality(RowMapperUtil.getString(rs, "nationality"));
formData.setReligion(rs.getString("religion")); formData.setReligion(RowMapperUtil.getString(rs, "religion"));
formData.setMotherTongue(rs.getString("mother_tongue")); formData.setMotherTongue(RowMapperUtil.getString(rs, "mother_tongue"));
formData.setCommunity(rs.getString("community")); formData.setCommunity(RowMapperUtil.getString(rs, "community"));
formData.setOtherChildren(rs.getString("other_children")); formData.setOtherChildren(RowMapperUtil.getString(rs, "other_children"));
formData.setMaritalStatus(rs.getString("marital_status")); formData.setMaritalStatus(RowMapperUtil.getString(rs, "marital_status"));
formData.setFatherName(rs.getString("father_name")); formData.setFatherName(RowMapperUtil.getString(rs, "father_name"));
formData.setFatherMobile(rs.getString("father_mobile")); formData.setFatherMobile(RowMapperUtil.getString(rs, "father_mobile"));
formData.setFatherEmail(rs.getString("father_email")); formData.setFatherEmail(RowMapperUtil.getString(rs, "father_email"));
formData.setFatherNationality(rs.getString("father_nationality")); formData.setFatherNationality(RowMapperUtil.getString(rs, "father_nationality"));
formData.setFatherReligion(rs.getString("father_religion")); formData.setFatherReligion(RowMapperUtil.getString(rs, "father_religion"));
formData.setFatherMotherTongue(rs.getString("father_mother_tongue")); formData.setFatherMotherTongue(RowMapperUtil.getString(rs, "father_mother_tongue"));
formData.setFatherCommunity(rs.getString("father_community")); formData.setFatherCommunity(RowMapperUtil.getString(rs, "father_community"));
formData.setFatherSchoolInfo(rs.getString("father_school_info")); formData.setFatherSchoolInfo(RowMapperUtil.getString(rs, "father_school_info"));
formData.setFatherCollegeInfo(rs.getString("father_college_info")); formData.setFatherCollegeInfo(RowMapperUtil.getString(rs, "father_college_info"));
formData.setFatherUniversityInfo(rs.getString("father_university_info")); formData.setFatherUniversityInfo(RowMapperUtil.getString(rs, "father_university_info"));
formData.setFatherProfessionalQualification(rs.getString("father_professional_qualification")); formData.setFatherProfessionalQualification(RowMapperUtil.getString(rs, "father_professional_qualification"));
formData.setFatherOccupation(rs.getString("father_occupation")); formData.setFatherOccupation(RowMapperUtil.getString(rs, "father_occupation"));
formData.setFatherMonthlyIncome(rs.getString("father_monthly_income")); formData.setFatherMonthlyIncome(RowMapperUtil.getString(rs, "father_monthly_income"));
formData.setFatherWorkplaceInfo(rs.getString("father_workplace_info")); formData.setFatherWorkplaceInfo(RowMapperUtil.getString(rs, "father_workplace_info"));
formData.setMotherName(rs.getString("mother_name")); formData.setMotherName(RowMapperUtil.getString(rs, "mother_name"));
formData.setMotherMobile(rs.getString("mother_mobile")); formData.setMotherMobile(RowMapperUtil.getString(rs, "mother_mobile"));
formData.setMotherEmail(rs.getString("mother_email")); formData.setMotherEmail(RowMapperUtil.getString(rs, "mother_email"));
formData.setMotherNationality(rs.getString("mother_nationality")); formData.setMotherNationality(RowMapperUtil.getString(rs, "mother_nationality"));
formData.setMotherReligion(rs.getString("mother_religion")); formData.setMotherReligion(RowMapperUtil.getString(rs, "mother_religion"));
formData.setMotherMotherTongue(rs.getString("mother_mother_tongue")); formData.setMotherMotherTongue(RowMapperUtil.getString(rs, "mother_mother_tongue"));
formData.setMotherCommunity(rs.getString("mother_community")); formData.setMotherCommunity(RowMapperUtil.getString(rs, "mother_community"));
formData.setMotherSchoolInfo(rs.getString("mother_school_info")); formData.setMotherSchoolInfo(RowMapperUtil.getString(rs, "mother_school_info"));
formData.setMotherCollegeInfo(rs.getString("mother_college_info")); formData.setMotherCollegeInfo(RowMapperUtil.getString(rs, "mother_college_info"));
formData.setMotherUniversityInfo(rs.getString("mother_university_info")); formData.setMotherUniversityInfo(RowMapperUtil.getString(rs, "mother_university_info"));
formData.setMotherProfessionalQualification(rs.getString("mother_professional_qualification")); formData.setMotherProfessionalQualification(RowMapperUtil.getString(rs, "mother_professional_qualification"));
formData.setMotherOccupation(rs.getString("mother_occupation")); formData.setMotherOccupation(RowMapperUtil.getString(rs, "mother_occupation"));
formData.setMotherMonthlyIncome(rs.getString("mother_monthly_income")); formData.setMotherMonthlyIncome(RowMapperUtil.getString(rs, "mother_monthly_income"));
formData.setMotherWorkplaceInfo(rs.getString("mother_workplace_info")); formData.setMotherWorkplaceInfo(RowMapperUtil.getString(rs, "mother_workplace_info"));
formData.setCandidateImageName(rs.getString("candidate_image_name")); formData.setCandidateImageName(RowMapperUtil.getString(rs, "candidate_image_name"));
formData.setFatherImageName(rs.getString("father_image_name")); formData.setFatherImageName(RowMapperUtil.getString(rs, "father_image_name"));
formData.setMotherImageName(rs.getString("mother_image_name")); formData.setMotherImageName(RowMapperUtil.getString(rs, "mother_image_name"));
formData.setInteractionDate(RowMapperUtil.getString(rs, "interaction_date"));
formData.setInteractionTime(RowMapperUtil.getString(rs, "interaction_time"));
return formData; return formData;
} }
......
package com.example.LaMartin.common.utils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Objects;
public class RowMapperUtil {
@Nullable
public static String getString(@NotNull ResultSet resultSet, String keyName) throws SQLException {
String data = resultSet.getString(keyName);
return Objects.equals(data, "null") ? null : data;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment