]> git.mxchange.org Git - jproduct-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 5 Nov 2022 07:07:03 +0000 (08:07 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 5 Nov 2022 07:07:03 +0000 (08:07 +0100)
- also compare primary keys

src/org/mxchange/jproduct/model/category/ProductCategory.java
src/org/mxchange/jproduct/model/product/GenericProduct.java

index 418b6ec1364bbfaa514b3d8794164edea73de64a..643aeb35a2b15222c517a32731617697ce619a31 100644 (file)
@@ -151,8 +151,10 @@ public class ProductCategory implements Category {
                final int comparators[] = {
                        // First check parent category
                        CategoryUtils.compare(this.getParentCategory(), category.getParentCategory()),
-                       // ... last is i18n key as it is unique
-                       StringUtils.compare(this.getCategoryI18nKey(), category.getCategoryI18nKey())
+                       // ... i18n key as it is unique
+                       StringUtils.compare(this.getCategoryI18nKey(), category.getCategoryI18nKey()),
+                       // ... primary key
+                       Long.compare(this.getCategoryId(), category.getCategoryId())
                };
 
                // Check all values
@@ -256,9 +258,9 @@ public class ProductCategory implements Category {
                int hash = 7;
 
                hash = 13 * hash + Objects.hashCode(this.getCategoryI18nKey());
-               hash = 13 * hash + Objects.hashCode(this.getCategoryId());
                hash = 13 * hash + Objects.hashCode(this.getCategoryShownInStatistics());
                hash = 13 * hash + Objects.hashCode(this.getParentCategory());
+               hash = 13 * hash + Objects.hashCode(this.getCategoryId());
 
                return hash;
        }
index 84a729453d9e8b19ce08645936836a9926b6464f..5642d8e22f417e87222cb6c20df0c34a12849705 100644 (file)
@@ -294,7 +294,9 @@ public class GenericProduct implements Product {
 
                // Init comparators
                final int comparators[] = {
-                       // First check product number
+                       // First compare id numbers
+                       Long.compare(this.getProductId(), product.getProductId()),
+                       // ... next product number
                        SafeNumberUtils.compare(this.getProductNumber(), product.getProductNumber()),
                        // ... bar-code number
                        StringUtils.compare(this.getProductBarCodeNumber(), product.getProductBarCodeNumber()),