details:   https://code.openbravo.com/erp/devel/pi/rev/c10f4c521f4a
changeset: 17716:c10f4c521f4a
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Mon Aug 20 16:55:03 2012 +0200
summary:   Fixed issue 21300. Synchronized initialization of DAL objects to 
prevent concurrent modification exception

details:   https://code.openbravo.com/erp/devel/pi/rev/1adc06c3a291
changeset: 17717:1adc06c3a291
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Mon Aug 20 17:31:36 2012 +0200
summary:   Fixed issue 20865. Disabled IsValueDisplayed for a reference to 
AD_Table, as it made no sense.

details:   https://code.openbravo.com/erp/devel/pi/rev/57f229938edf
changeset: 17718:57f229938edf
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Mon Aug 20 17:35:10 2012 +0200
summary:   Fixed issue 20822. Changed slightly how reference data is applied.
- Before, for System/Client tables, it was assumed that the 'system' part 
should be searched just by id. This is unfortunately wrong, as it could happen 
that data in the same table could be loaded as 'client', and after that, as 
'system'. In this situation, the data loaded as system would have different ids.
- The fix basically consists in searching the data at system level using the 
AD_Ref_Data_Loaded information. Retrieving the records this way will ensure 
that the correct ids are used, and that data at System/Client tables is 
correctly found.

diffstat:

 
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REF_TABLE.xml
                                                |   2 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ApplicationDictionaryCachedStructures.java
 |  46 +++++----
 src/org/openbravo/dal/xml/EntityResolver.java                                  
                                                 |  17 +++
 3 files changed, 43 insertions(+), 22 deletions(-)

diffs (156 lines):

diff -r 7b1047b06a8d -r 57f229938edf 
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REF_TABLE.xml
--- 
a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REF_TABLE.xml
  Mon Aug 20 15:25:59 2012 +0200
+++ 
b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REF_TABLE.xml
  Mon Aug 20 17:35:10 2012 +0200
@@ -8,7 +8,7 @@
 <!--414E5DD3A1304C7781FB856A6872F428-->  
<AD_TABLE_ID><![CDATA[100]]></AD_TABLE_ID>
 <!--414E5DD3A1304C7781FB856A6872F428-->  <AD_KEY><![CDATA[100]]></AD_KEY>
 <!--414E5DD3A1304C7781FB856A6872F428-->  
<AD_DISPLAY><![CDATA[107]]></AD_DISPLAY>
-<!--414E5DD3A1304C7781FB856A6872F428-->  
<ISVALUEDISPLAYED><![CDATA[Y]]></ISVALUEDISPLAYED>
+<!--414E5DD3A1304C7781FB856A6872F428-->  
<ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
 <!--414E5DD3A1304C7781FB856A6872F428--></AD_REF_TABLE>
 
 <!--5E77652CBFEB4F03A3A0629642D024BD--><AD_REF_TABLE>
diff -r 7b1047b06a8d -r 57f229938edf 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ApplicationDictionaryCachedStructures.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ApplicationDictionaryCachedStructures.java
   Mon Aug 20 15:25:59 2012 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ApplicationDictionaryCachedStructures.java
   Mon Aug 20 17:35:10 2012 +0200
@@ -75,11 +75,11 @@
       return tabMap.get(tabId);
     }
     Tab tab = OBDal.getInstance().get(Tab.class, tabId);
-    Hibernate.initialize(tab);
-    Hibernate.initialize(tab.getADAuxiliaryInputList());
-    Hibernate.initialize(tab.getADFieldList());
-    Hibernate.initialize(tab.getTable());
-    Hibernate.initialize(tab.getTable().getADColumnList());
+    initializeDALObject(tab);
+    initializeDALObject(tab.getADAuxiliaryInputList());
+    initializeDALObject(tab.getADFieldList());
+    initializeDALObject(tab.getTable());
+    initializeDALObject(tab.getTable().getADColumnList());
     tabMap.put(tabId, tab);
     return tab;
   }
@@ -89,8 +89,8 @@
       return tableMap.get(tableId);
     }
     Table table = OBDal.getInstance().get(Table.class, tableId);
-    Hibernate.initialize(table);
-    Hibernate.initialize(table.getADColumnList());
+    initializeDALObject(table);
+    initializeDALObject(table.getADColumnList());
     tableMap.put(tableId, table);
     return table;
   }
@@ -105,7 +105,7 @@
       if (f.getColumn() == null) {
         continue;
       }
-      Hibernate.initialize(f.getColumn());
+      initializeDALObject(f.getColumn());
       initializeColumn(f.getColumn());
     }
     fieldMap.put(tabId, fields);
@@ -127,20 +127,20 @@
 
   private void initializeColumn(Column c) {
 
-    Hibernate.initialize(c.getValidation());
+    initializeDALObject(c.getValidation());
     if (c.getValidation() != null) {
-      Hibernate.initialize(c.getValidation().getValidationCode());
+      initializeDALObject(c.getValidation().getValidationCode());
     }
     if (c.getCallout() != null) {
-      Hibernate.initialize(c.getCallout());
-      Hibernate.initialize(c.getCallout().getADModelImplementationList());
+      initializeDALObject(c.getCallout());
+      initializeDALObject(c.getCallout().getADModelImplementationList());
       for (ModelImplementation imp : 
c.getCallout().getADModelImplementationList()) {
-        Hibernate.initialize(imp);
+        initializeDALObject(imp);
       }
     }
 
     if (c.getReference() != null) {
-      Hibernate.initialize(c.getReference());
+      initializeDALObject(c.getReference());
       initializeReference(c.getReference());
     }
     if (c.getReferenceSearchKey() != null) {
@@ -149,15 +149,15 @@
   }
 
   private void initializeReference(Reference reference) {
-    Hibernate.initialize(reference.getADReferencedTableList());
+    initializeDALObject(reference.getADReferencedTableList());
     for (ReferencedTable t : reference.getADReferencedTableList()) {
-      Hibernate.initialize(t);
+      initializeDALObject(t);
     }
-    Hibernate.initialize(reference.getOBUISELSelectorList());
+    initializeDALObject(reference.getOBUISELSelectorList());
     for (Selector s : reference.getOBUISELSelectorList()) {
-      Hibernate.initialize(s);
+      initializeDALObject(s);
       SelectorField displayField = s.getDisplayfield();
-      Hibernate.initialize(displayField);
+      initializeDALObject(displayField);
     }
 
   }
@@ -167,15 +167,19 @@
       return auxInputMap.get(tabId);
     }
     Tab tab = getTab(tabId);
-    Hibernate.initialize(tab.getADAuxiliaryInputList());
+    initializeDALObject(tab.getADAuxiliaryInputList());
     List<AuxiliaryInput> auxInputs = new 
ArrayList<AuxiliaryInput>(tab.getADAuxiliaryInputList());
     for (AuxiliaryInput auxIn : auxInputs) {
-      Hibernate.initialize(auxIn);
+      initializeDALObject(auxIn);
     }
     auxInputMap.put(tabId, auxInputs);
     return auxInputs;
   }
 
+  private synchronized void initializeDALObject(Object obj) {
+    Hibernate.initialize(obj);
+  }
+
   public ComboTableData getComboTableData(VariablesSecureApp vars, String ref, 
String colName,
       String objectReference, String validation, String orgList, String 
clientList) {
     String comboId = ref + colName + objectReference + validation + orgList + 
clientList;
diff -r 7b1047b06a8d -r 57f229938edf 
src/org/openbravo/dal/xml/EntityResolver.java
--- a/src/org/openbravo/dal/xml/EntityResolver.java     Mon Aug 20 15:25:59 
2012 +0200
+++ b/src/org/openbravo/dal/xml/EntityResolver.java     Mon Aug 20 17:35:10 
2012 +0200
@@ -245,6 +245,9 @@
       // search client and system
       result = searchClientRefLoaded(id, entity, refLoadeds);
       if (result == null) {
+        result = searchSystemRefLoaded(id, entity, refLoadeds);
+      }
+      if (result == null) {
         result = searchSystem(id, entity);
       }
     } else if (al == AccessLevel.CLIENT) {
@@ -338,6 +341,20 @@
     return doSearch(id, entity, client.getId(), "0");
   }
 
+  private BaseOBObject searchSystemRefLoaded(String id, Entity entity,
+      List<RefDataLoaded> refLoadeds) {
+    BaseOBObject result = null;
+    for (RefDataLoaded refLoaded : refLoadeds) {
+      if (refLoaded.getClientId().equals('0') && 
refLoaded.getOrgId().equals("0")) {
+        result = doSearch(refLoaded.getSpecificId(), entity, "0", "0");
+        if (result != null) {
+          return result;
+        }
+      }
+    }
+    return doSearch(id, entity, "0", "0");
+  }
+
   public String getOriginalId(BaseOBObject bob) {
     return objectOriginalIdMapping.get(bob);
   }

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to