You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Patrick Antivackis <pa...@gmail.com> on 2009/10/22 21:29:31 UTC

Bug in GenericDelegator storeAll ?

Hello,
I'm wondering if in
framework/entity/src/org/ofbiz/entity/GenericDelegator.java on line 1384 the
expression :
if ((fieldValue == null && oldValue != null) || (fieldValue != null &&
!fieldValue.equals(oldValue)))
shouldn't use compareTo instead of equals as in the GenericEntity class
where all compare are done through compareTo/compareToFields.

The issue with the equals instead of compareTo is for example when you
import an XML file updating ProductPrice, all productPrices will be updated
instead of just the ones that are not the same because prices in XML files
are not BigInteger.equals but just BigInteger.compareTo.

Not sure I'm clear. But if you make a ant run-install (normally loading demo
datas) and then you pick up the lines :
    <ProductPrice productId="GZ-1000" productPricePurposeId="PURCHASE"
productPriceTypeId="DEFAULT_PRICE" currencyUomId="USD"
productStoreGroupId="_NA_" fromDate="2001-05-13 12:00:00.0" price="15.99"
createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin"
lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
    <ProductPrice productId="GZ-1000" productPricePurposeId="PURCHASE"
productPriceTypeId="LIST_PRICE" currencyUomId="USD"
productStoreGroupId="_NA_" fromDate="2001-05-13 12:00:00.0" price="15.0"
createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin"
lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>

from specialpurpose/ecommerce/data/DemoProduct.xml and run then in the
import XML engine, the concerned lines will be updated in the database and
their Timestamp will be updated.

changing the first data price by 15.990 and the second by 15.000 will not
update the existing datas.

So should the "equals" be changed or should it be the demo data values ?

Regards

Re: Bug in GenericDelegator storeAll ?

Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Patrick,

Did you find any drawbacks further than distinction between 15.99 and 15.990 ?

Jacques

From: "Patrick Antivackis" <pa...@gmail.com>
> Hello,
> I'm wondering if in
> framework/entity/src/org/ofbiz/entity/GenericDelegator.java on line 1384 the
> expression :
> if ((fieldValue == null && oldValue != null) || (fieldValue != null &&
> !fieldValue.equals(oldValue)))
> shouldn't use compareTo instead of equals as in the GenericEntity class
> where all compare are done through compareTo/compareToFields.
> 
> The issue with the equals instead of compareTo is for example when you
> import an XML file updating ProductPrice, all productPrices will be updated
> instead of just the ones that are not the same because prices in XML files
> are not BigInteger.equals but just BigInteger.compareTo.
> 
> Not sure I'm clear. But if you make a ant run-install (normally loading demo
> datas) and then you pick up the lines :
>    <ProductPrice productId="GZ-1000" productPricePurposeId="PURCHASE"
> productPriceTypeId="DEFAULT_PRICE" currencyUomId="USD"
> productStoreGroupId="_NA_" fromDate="2001-05-13 12:00:00.0" price="15.99"
> createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin"
> lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
>    <ProductPrice productId="GZ-1000" productPricePurposeId="PURCHASE"
> productPriceTypeId="LIST_PRICE" currencyUomId="USD"
> productStoreGroupId="_NA_" fromDate="2001-05-13 12:00:00.0" price="15.0"
> createdDate="2001-05-13 12:00:00.0" createdByUserLogin="admin"
> lastModifiedDate="2001-05-13 12:00:00.0" lastModifiedByUserLogin="admin"/>
> 
> from specialpurpose/ecommerce/data/DemoProduct.xml and run then in the
> import XML engine, the concerned lines will be updated in the database and
> their Timestamp will be updated.
> 
> changing the first data price by 15.990 and the second by 15.000 will not
> update the existing datas.
> 
> So should the "equals" be changed or should it be the demo data values ?
> 
> Regards
>