for(ItemDetail id : itemDetails){
if(id.getSerialNo().equalsIgnoreCase(txtSerialNumber.getText())){
r = false;
}
}
ItemDetail temp = (ItemDetail) sess.createQuery("FROM "+ItemDetail.class.getName()+" as itd WHERE itd.status<>:status and itd.itemWarehouse=:item and itd.serialNo=:sn")
.setParameter("status", ItemDetail.SOLD)
.setParameter("item", itemWarehouse)
.setParameter("sn", txtSerialNumber.getText())
.uniqueResult();
if(temp == null){
r = false;
}
if(r){
ItemDetail itemDetail = temp;
itemDetails.add(itemDetail);
model.addRow(new Object[]{txtSerialNumber.getText(), txtItemsType.getText()});
} else {
JOptionPane.showMessageDialog(this, "Serial Number doesn't exist");
}