您好,我试图从HashSet中删除一个具有由我创建的称为“ Product”的实体的元素,这是代码:
Set listaItemsTrans = this.getTransaction().getTransactionItems();
HashSet listaIteratorI = new HashSet();
listaIteratorI.addAll(listaItemsTrans);
Iterator itemSet = listaIteratorI.iterator();
while (itemSet.hasNext())
{
Product prodBif = (Product) itemSet.next();
logger.debug("Prod bif = " + prodBif.getIdProduct() + " = " + "Prod search = " + prodSearch.getIdProduct());
if (prodBif.getIdProduct().compareTo(prodSearch.getIdProduct()) == 0)
{
logger.debug("El Producto ha sido encontrado");
try
{
logger.debug("ProdBif " + prodBif);
logger.debug("Lista de productos 3 " + this.getTransaction().getTransactionItems());
boolean isRemoved;
isRemoved = this.getTransaction().getTransactionItems().remove(prodBif);
logger.debug("isRemoved? " + isRemoved);
}
catch (Exception e)
{
e.printStackTrace();
}
logger.debug("Lista de productos 4" + this.getTransaction().getTransactionItems());
prodBif = prodSearch;
this.getTransaction().getTransactionItems().add(prodBif);
logger.debug("Lista de productos 5" + this.getTransaction().getTransactionItems());
isOkey = true;
}
}
产品是相同的,我已经检查过,但是我要把产品相等:
Product Bif: Product [idProduct=1546405266442777, transaction=Transaction [idTransaction=1546405253162777, transaction=077700514, transactionDate=2019-01-02 10:01:06, session=Session [idSession=1546405226194777, session=00130777000000011111, cashier=com.lds.exito.darchitecture.domainmodel.entities.Cashier@d8241df3, store=Store [idStore=1546405226193777, store=0013, description=EXTITO GRAN VIA M001120], terminal=777, sessionDate=2019-01-02 10:00:26], sequenceNumber=0514, ], pluVariety=000000213690, salePrice=9900, description=NEVERA NO FROST 39, details={CashierID=0000011111, mensaje=Certificado valido, TransactionID=0514, AuthorizationBus=CommunicationHttpBodyAuthBus, ValidationResponseRevertionStatus=com.lds.exito.soa.status.validation.IvaDifResponseStatusValidation, portPrimary=, hostPrimary=http://wsredverde.datagestion.co/ws/?a=2&certificado=3&identificacion=8276946&codigo=13, contentType=application/json, StoreID=0013, PREFIX_AUTH_END_identificacion==8276946, OriginalTerminalID=777, nroIdentificacion=8276946, uri=, AuthorizationClassName=FinalAuthorizationHttp, plu=000000213690, PREFIX_AUTH_END_certificado==3, TerminalID=777, fechaHora=2019-01-02T10:01:06, nroCertificado=3, OriginalTransactionID=0514}, extras={transaction_record=IvaDif/IvaDif-99-129,,, voucher_list=IvaDif/FooterRecarga,}, authorizationType=ParametersConfig [idParameter=2, descriptionGroup=Tipos de Autorizacion, idGroup=TPAUT, descriptionParameter=Autorizacion al Final de la Transaccion, parameterValue=ENDTR], authorizationStatus=ParametersConfig [idParameter=3, descriptionGroup=Estado de la Autorizacion, idGroup=STAUT, descriptionParameter=Pendiente, parameterValue=PNDNG], reverseType=ParametersConfig [idParameter=7, descriptionGroup=Tipos de Reverso, idGroup=TPREV, descriptionParameter=No Aplica, parameterValue=NOAPP], reverseStatus=ParametersConfig [idParameter=8, descriptionGroup=Estado del Reverso, idGroup=STREV, descriptionParameter=No Aplica, parameterValue=NOAPP], anulationType=ParametersConfig [idParameter=11, descriptionGroup=Tipos de Anulacion, idGroup=TPANU, descriptionParameter=Aplica, parameterValue=APPLY], anulationStatus=ParametersConfig [idParameter=13, descriptionGroup=Estado del Anulacion, idGroup=STANU, descriptionParameter=No Aplica, parameterValue=NOAPP], productType=ParametersConfig [idParameter=16, descriptionGroup=Tipos de Producto, idGroup=TPPDT, descriptionParameter=Item, parameterValue=ITEM], quantity=1, ]
Product in the HashSet: Product [idProduct=1546405266442777, transaction=Transaction [idTransaction=1546405253162777, transaction=077700514, transactionDate=2019-01-02 10:01:06, session=Session [idSession=1546405226194777, session=00130777000000011111, cashier=com.lds.exito.darchitecture.domainmodel.entities.Cashier@d8241df3, store=Store [idStore=1546405226193777, store=0013, description=EXTITO GRAN VIA M001120], terminal=777, sessionDate=2019-01-02 10:00:26], sequenceNumber=0514, ], pluVariety=000000213690, salePrice=9900, description=NEVERA NO FROST 39, details={CashierID=0000011111, mensaje=Certificado valido, TransactionID=0514, AuthorizationBus=CommunicationHttpBodyAuthBus, ValidationResponseRevertionStatus=com.lds.exito.soa.status.validation.IvaDifResponseStatusValidation, portPrimary=, hostPrimary=http://wsredverde.datagestion.co/ws/?a=2&certificado=3&identificacion=8276946&codigo=13, contentType=application/json, StoreID=0013, PREFIX_AUTH_END_identificacion==8276946, OriginalTerminalID=777, nroIdentificacion=8276946, uri=, AuthorizationClassName=FinalAuthorizationHttp, plu=000000213690, PREFIX_AUTH_END_certificado==3, TerminalID=777, fechaHora=2019-01-02T10:01:06, nroCertificado=3, OriginalTransactionID=0514}, extras={transaction_record=IvaDif/IvaDif-99-129,,, voucher_list=IvaDif/FooterRecarga,}, authorizationType=ParametersConfig [idParameter=2, descriptionGroup=Tipos de Autorizacion, idGroup=TPAUT, descriptionParameter=Autorizacion al Final de la Transaccion, parameterValue=ENDTR], authorizationStatus=ParametersConfig [idParameter=3, descriptionGroup=Estado de la Autorizacion, idGroup=STAUT, descriptionParameter=Pendiente, parameterValue=PNDNG], reverseType=ParametersConfig [idParameter=7, descriptionGroup=Tipos de Reverso, idGroup=TPREV, descriptionParameter=No Aplica, parameterValue=NOAPP], reverseStatus=ParametersConfig [idParameter=8, descriptionGroup=Estado del Reverso, idGroup=STREV, descriptionParameter=No Aplica, parameterValue=NOAPP], anulationType=ParametersConfig [idParameter=11, descriptionGroup=Tipos de Anulacion, idGroup=TPANU, descriptionParameter=Aplica, parameterValue=APPLY], anulationStatus=ParametersConfig [idParameter=13, descriptionGroup=Estado del Anulacion, idGroup=STANU, descriptionParameter=No Aplica, parameterValue=NOAPP], productType=ParametersConfig [idParameter=16, descriptionGroup=Tipos de Producto, idGroup=TPPDT, descriptionParameter=Item, parameterValue=ITEM], quantity=1, ]
我不知道为什么会这样,我想念的东西吗?
注意1:,当我尝试使用具有代码功能的其他产品做相同的事情
注意2:我受硬件限制使用Java 1.4