Hi friends,
I m new to Java.I m working on Librarian Project, I have made data model to display data in Jtable..The situation is that I have made disposal form to store information abt those book which are disposed..Now end user have three option to dispose book say Sold, Damaged and Lost..So once the when the user try to disposal the same book which is already disposed then the form shud give error msg that the book is already sold or lost whatever...I have written the code for it..but it is showing only lost situation in every scenario... so please correct my code where i m wrong..
private void fetchAccessionRegisterData(String accessionRegisterNumber, int row) { //AccessionRegister accessionRegister = new AccessionRegister(); //accessionRegister.setAccessionRegisterId(UUID.randomUUID().toString()); String hql = "from AccessionRegister ar where ar.accessionRegisterNumber='" + accessionRegisterNumber + "'"; Query q = m_Session.createQuery(hql); List<AccessionRegister> setDetails = q.list(); Iterator<AccessionRegister> iDetails = setDetails.iterator(); //System.out.println("RowCount:"+m_Model.getRowCount()); if (iDetails.hasNext()) { m_AccessionRegister = iDetails.next(); System.out.println("Accession Register Number:" + m_AccessionRegister.getAccessionRegisterNumber() + ":isLost:" + m_AccessionRegister.isIsLost() + ":isSold:" + m_AccessionRegister.isIsSold()); if (m_AccessionRegister.isIsLost()) { m_FeedbackHandler.handleFeedback("This item is already marked as Lost"); m_Model.setValueAt(" ", row, IDX_ACCESSION_REGISTER_NUMBER); return; } else if (m_AccessionRegister.isIsSold()) { m_FeedbackHandler.handleFeedback("This item is already marked as Sold"); m_Model.setValueAt(" ", row, IDX_ACCESSION_REGISTER_NUMBER); return; } else if(m_AccessionRegister.equals(m_AccessionRegister.getAccessionRegisterNumber())){ m_Model.setValueAt(" ", row, IDX_ACCESSION_REGISTER_NUMBER); m_FeedbackHandler.handleFeedback("This is an invalid Accession Register Number"); } if (m_frmDisposal.isSold()) { m_AccessionRegister.setIsSold(true); } else if (m_frmDisposal.isLost()) { m_AccessionRegister.setIsLost(true); }