I have a Question Bean:
public class Question implements IHaveId, IAuditable {
private long id;
private QuestionType questionType;
private String questionText;
private String questionHint;
private RenderMode renderMode;
...
Normal Bean getters and setters here
...
}
and another Answer Bean, note the two extra getters and setters for the Question Attribute : getQuestionId and setQuestionId
public class Answer implements IHaveId, IAuditable {
private long id;
private String answerValue;
private DataType dataType = DataType.UNKNOWN;
private Question question;
...
javabean getters and setters here
...
//Kindly note these extra two getters and setters
public Long getQuestionId() {
return question == null ? null : question.getId();
}
public void setQuestionId(Long questionId) {
if(questionId == null)return;
question = new Question();
question.setId(questionId);
}
}
I am using the Answer Bean as a BeanPropertySqlParameterSource when calling a Stored procedure using SimpleJdbcCall.
Map m = pspCreate.execute(in) = new BeanPropertySqlParameterSource(answer);
The parameters of the Stored procedure are the primitive type properties of the Answer Object with the id of the Object type properties.
For instance if a have a question_id parameter, JavaBean Reflection uses getQuestionId
How do I avoid this avoid adding the getQuestionId because it kind of duplicates the question Attribute?
Aucun commentaire:
Enregistrer un commentaire