I have a large ResultSet(receiving from a request JDBC) several thousand rows. Using each of these lines, I have to create an instance Object, setting it according to the fields of this result set. Now, as we all know, methods of getXXX()this JDBC APIreturn 0if this column was null. Therefore, for each field of each row, I have to do wasNull()before setting the value in mine Object, which looks pretty ugly and can be inefficient. So, is there any other way I can avoid this?
Besides JDBC, if there is some completely different, standard, commonly used way, I can also find out about it.
Thank!
EDIT 1
patientInput.setRaceCodeId(patients.getShort("race_code_id"));
if(patients.wasNull())
patientInput.setRaceCodeId(null);
patientsis ResultSet. patientInputis Object. This is the code I'm trying to avoid. I mean, every time I do getXXX()and do setXXX(), I have to check again that what I got from ResultSetwas not null. If so, then set this field of the object as null, since it getXXX()returns 0in this case.
source
share