I have the following codes below:
private Integer mTarifId;
public Integer getTarifId() {
return mTarifId;
}
public void setTarifId(Integer tarifId) {
this.mTarifId = tarifId;
}
I have initialized a variable named 'mTarifId'. And i need to use it in the code below.
if (!Objects.equals(mTarifId, null)) {
query = mEntityManager.createQuery("FROM TarifListeCalendrierEntity WHERE tarifListeId=:pId")
.setParameter("pId", mTarifId);
List<TarifListeCalendrierEntity> tarifListCalendrierList = query.getResultList();
if (!tarifListCalendrierList.isEmpty()) {
TarifListeCalendrierEntity tarifListCalendrier = tarifListCalendrierList.get(0);
request.setAttribute("tarif_list_calendrier", tarifListCalendrier);
}
}
But in order to do so i need to convert it to an integer in the 'doGet'
String tarifId = request.getParameter("tarifid");
if (!Objects.equals(tarifId, null)) {
setTarifId(Integer.valueOf(tarifId));
}else {
setTarifId(null);
}
Please help identify what i'm doing wrong.