Bug in GenericDelegator storeAll ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug in GenericDelegator storeAll ?

Patrick Antivackis
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
Reply | Threaded
Open this post in threaded view
|

Re: Bug in GenericDelegator storeAll ?

Jacques Le Roux
Administrator
Hi Patrick,

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

Jacques

From: "Patrick Antivackis" <[hidden email]>

> 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
>