You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2013/11/10 17:43:20 UTC

svn commit: r1540491 - in /ofbiz/branches/release13.07: ./ framework/base/src/org/ofbiz/base/util/ framework/common/servicedef/ framework/entity/dtd/ framework/entity/src/org/ofbiz/entity/ framework/entity/src/org/ofbiz/entity/test/ framework/webtools/...

Author: adrianc
Date: Sun Nov 10 16:43:20 2013
New Revision: 1540491

URL: http://svn.apache.org/r1540491
Log:
Merged revision(s) 1526276 from ofbiz/trunk:
Fixed a warning caused by a framework dependency on the Party component.

Merged revision(s) 1527626 from ofbiz/trunk:
Fixed a subtle flaw in the GenericDelegator.findOne method. When a database query returns no result, GenericValue.NULL_VALUE is put in the pk cache - so future findOne calls will know the entity value doesn't exist. But the findOne method never checked for GenericValue.NULL_VALUE in cache gets, so the database was queried again for an entity value we already know doesn't exist.

https://issues.apache.org/jira/browse/OFBIZ-5332

Merged revision(s) 1527609 from ofbiz/trunk:
Small change to GenericDelegator.findOne method - moved the primary key validation check to the beginning of the method.

I believe the original intention was to perform the validation check after the EV_VALIDATE ECAs were run, but the primary key was being used in three method calls before that happened - so those methods could have been passed an invalid primary key.

Merged revision(s) 1527212 from ofbiz/trunk:
Replaced HashSet with LinkedHashSet in UtilMisc.java to preserve original ordering. Suggested by Leon on the dev mailing list.

Merged revision(s) 1527810 from ofbiz/trunk:
Fixed a problem with bad try-catch-finally nesting and transaction handling in GenericDelegator.

1. The only exception caught was GenericEntityException, so any other thrown exception was missed - meaning the transaction was committed and GenericDelegator acted as if nothing was wrong.

2. The commit was performed in the finally block, so it was ALWAYS performed - even after an exception was thrown and the transaction was rolled back.

We managed to get away with this all along because typically there is a wrapping transaction that clears it all up. But still, the Delegator code needs to handle transactions correctly.

Merged revision(s) 1530976 from ofbiz/trunk:
Allow redefinition of view entities. XML schema change only - implementation exists already.

Merged revision(s) 1533542 from ofbiz/trunk:
Fixed a bug in the entity tests - JUnit expected and actual arguments were reversed in the testTransactionUtilRollback test.

Merged revision(s) 1536170 from ofbiz/trunk:
Small fix for StringUtil.toMap method - avoid array index exceptions when a Map element is missing a value.

Merged revision(s) 1539781 from ofbiz/trunk:
Fixed broken ModelInduceFromDb.jsp file.

Modified:
    ofbiz/branches/release13.07/   (props changed)
    ofbiz/branches/release13.07/framework/base/src/org/ofbiz/base/util/StringUtil.java
    ofbiz/branches/release13.07/framework/common/servicedef/services.xml
    ofbiz/branches/release13.07/framework/entity/dtd/entitymodel.xsd
    ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
    ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java
    ofbiz/branches/release13.07/framework/webtools/webapp/webtools/entity/ModelInduceFromDb.jsp

Propchange: ofbiz/branches/release13.07/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1526276,1527609,1527626,1527810,1530976,1533542,1536170,1539781

Modified: ofbiz/branches/release13.07/framework/base/src/org/ofbiz/base/util/StringUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1540491&r1=1540490&r2=1540491&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/base/src/org/ofbiz/base/util/StringUtil.java (original)
+++ ofbiz/branches/release13.07/framework/base/src/org/ofbiz/base/util/StringUtil.java Sun Nov 10 16:43:20 2013
@@ -377,7 +377,9 @@ public class StringUtil {
     }
     
     /**
-     * Reads a String version of a Map (should contain only strings) and creates a new Map
+     * Reads a String version of a Map (should contain only strings) and creates a new Map.
+     * Partial Map elements are skipped: <code>{foo=fooValue, bar=}</code> will contain only
+     * the foo element.
      *
      * @param s String value of a Map ({n1=v1, n2=v2})
      * @return new Map
@@ -389,7 +391,9 @@ public class StringUtil {
             String[] entries = s.split("\\,\\s");
             for (String entry: entries) {
                 String[] nv = entry.split("\\=");
-                newMap.put(nv[0], nv[1]);
+                if (nv.length == 2) {
+                    newMap.put(nv[0], nv[1]);
+                }
             }
         } else {
             throw new IllegalArgumentException("String is not from Map.toString()");

Modified: ofbiz/branches/release13.07/framework/common/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/common/servicedef/services.xml?rev=1540491&r1=1540490&r2=1540491&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/common/servicedef/services.xml (original)
+++ ofbiz/branches/release13.07/framework/common/servicedef/services.xml Sun Nov 10 16:43:20 2013
@@ -181,9 +181,9 @@ under the License.
         <description>Create a CustomTimePeriod record</description>
         <auto-attributes mode="OUT" include="pk" optional="false"/>
         <auto-attributes mode="IN" include="nonpk" optional="true"/>
+        <attribute name="organizationPartyId" type="String" mode="IN" optional="false"/><!-- FIXME: Framework dependency on Party component -->
         <override name="fromDate" optional="false"/>
         <override name="thruDate" optional="false"/>
-        <override name="organizationPartyId" optional="false"/>
         <override name="periodTypeId" optional="false"/>
     </service>
     <service name="updateCustomTimePeriod" default-entity-name="CustomTimePeriod" engine="simple"

Modified: ofbiz/branches/release13.07/framework/entity/dtd/entitymodel.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/entity/dtd/entitymodel.xsd?rev=1540491&r1=1540490&r2=1540491&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/entity/dtd/entitymodel.xsd (original)
+++ ofbiz/branches/release13.07/framework/entity/dtd/entitymodel.xsd Sun Nov 10 16:43:20 2013
@@ -256,6 +256,15 @@ under the License.
         <xs:attribute name="copyright" type="xs:string"/>
         <xs:attribute name="author" type="xs:string"/>
         <xs:attribute name="version" type="xs:string"/>
+        <xs:attribute name="redefinition" type="boolean">
+            <xs:annotation>
+                <xs:documentation>
+                    Indicates if this entity redefines an existing entity.
+                    When set to "true" it will suppress "Entity is defined more than once" warnings.
+                    Defaults to "false".
+                </xs:documentation>
+            </xs:annotation>
+        </xs:attribute>
     </xs:attributeGroup>
     <xs:element name="member-entity">
         <xs:complexType>

Modified: ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=1540491&r1=1540490&r2=1540491&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Sun Nov 10 16:43:20 2013
@@ -811,22 +811,13 @@ public class GenericDelegator implements
             }
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_CREATE, value, false);
-
+            TransactionUtil.commit(beganTransaction);
             return value;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in createSetNextSeqId operation for entity [" + value.getEntityName() + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -877,22 +868,13 @@ public class GenericDelegator implements
             }
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_CREATE, value, false);
-
+            TransactionUtil.commit(beganTransaction);
             return value;
-        } catch (GenericEntityException e) {
-            String errMsg = "Failure in create operation for entity [" + (value != null ? value.getEntityName() : "null")  + "]: " + e.toString() + ". Rolling back transaction.";
+        } catch (Exception e) {
+            String errMsg = "Failure in create operation for entity [" + (value != null ? value.getEntityName() : "null") + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -915,22 +897,13 @@ public class GenericDelegator implements
             if (value.lockEnabled()) {
                 this.refresh(value);
             }
-
+            TransactionUtil.commit(beganTransaction);
             return value;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in createOrStore operation for entity [" + value.getEntityName() + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1019,22 +992,13 @@ public class GenericDelegator implements
             }
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_REMOVE, primaryKey, false);
-
+            TransactionUtil.commit(beganTransaction);
             return num;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in removeByPrimaryKey operation for entity [" + primaryKey.getEntityName() + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1091,22 +1055,13 @@ public class GenericDelegator implements
             this.saveEntitySyncRemoveInfo(value.getPrimaryKey());
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_REMOVE, value, false);
-
+            TransactionUtil.commit(beganTransaction);
             return num;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in removeValue operation for entity [" + value.getEntityName() + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1175,22 +1130,13 @@ public class GenericDelegator implements
                     storeForTestRollback(new TestOperation(OperationType.DELETE, entity));
                 }
             }
-
+            TransactionUtil.commit(beganTransaction);
             return rowsAffected;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in removeByCondition operation for entity [" + entityName + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1285,22 +1231,13 @@ public class GenericDelegator implements
                     storeForTestRollback(new TestOperation(OperationType.UPDATE, entity));
                 }
             }
-
+            TransactionUtil.commit(beganTransaction);
             return rowsAffected;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in storeByCondition operation for entity [" + entityName + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1354,22 +1291,13 @@ public class GenericDelegator implements
             }
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_STORE, value, false);
-
+            TransactionUtil.commit(beganTransaction);
             return retVal;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in store operation for entity [" + value.getEntityName() + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1452,22 +1380,13 @@ public class GenericDelegator implements
                     }
                 }
             }
-
+            TransactionUtil.commit(beganTransaction);
             return numberChanged;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in storeAll operation: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1504,22 +1423,13 @@ public class GenericDelegator implements
                     numRemoved += this.removeByAnd(value.getEntityName(), value.getAllFields(), doCacheClear);
                 }
             }
-
+            TransactionUtil.commit(beganTransaction);
             return numRemoved;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in removeAll operation: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1539,11 +1449,16 @@ public class GenericDelegator implements
      */
     public GenericValue findOne(String entityName, Map<String, ? extends Object> fields, boolean useCache) throws GenericEntityException {
         GenericPK primaryKey = this.makePK(entityName, fields);
+        if (!primaryKey.isPrimaryKey()) {
+            throw new GenericModelException("[GenericDelegator.findOne] Passed primary key is not a valid primary key: " + primaryKey);
+        }
         EntityEcaRuleRunner<?> ecaRunner = this.getEcaRuleRunner(entityName);
         if (useCache) {
             ecaRunner.evalRules(EntityEcaHandler.EV_CACHE_CHECK, EntityEcaHandler.OP_FIND, primaryKey, false);
-
-            GenericValue value = this.getFromPrimaryKeyCache(primaryKey);
+            GenericValue value = cache.get(primaryKey);
+            if (value == GenericValue.NULL_VALUE) {
+                return null;
+            }
             if (value != null) {
                 return value;
             }
@@ -1560,9 +1475,6 @@ public class GenericDelegator implements
             GenericHelper helper = getEntityHelper(entityName);
             GenericValue value = null;
 
-            if (!primaryKey.isPrimaryKey()) {
-                throw new GenericModelException("[GenericDelegator.findOne] Passed primary key is not a valid primary key: " + primaryKey);
-            }
             ecaRunner.evalRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, primaryKey, false);
             try {
                 value = helper.findByPrimaryKey(primaryKey);
@@ -1583,21 +1495,13 @@ public class GenericDelegator implements
             }
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, (value == null ? primaryKey : value), false);
+            TransactionUtil.commit(beganTransaction);
             return value;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in findOne operation for entity [" + entityName + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1656,21 +1560,13 @@ public class GenericDelegator implements
             if (value != null) value.setDelegator(this);
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, primaryKey, false);
+            TransactionUtil.commit(beganTransaction);
             return value;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in findByPrimaryKeyPartial operation for entity [" + primaryKey.getEntityName() + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1800,21 +1696,13 @@ public class GenericDelegator implements
                 ecaRunner.evalRules(EntityEcaHandler.EV_CACHE_PUT, EntityEcaHandler.OP_FIND, dummyValue, false);
                 this.cache.put(entityName, entityCondition, orderBy, list);
             }
+            TransactionUtil.commit(beganTransaction);
             return list;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in findByCondition operation for entity [" + entityName + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1875,21 +1763,13 @@ public class GenericDelegator implements
             long count = helper.findCountByCondition(modelEntity, whereEntityCondition, havingEntityCondition, findOptions);
 
             ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, dummyValue, false);
+            TransactionUtil.commit(beganTransaction);
             return count;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in findListIteratorByCondition operation for entity [DynamicView]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -1912,22 +1792,14 @@ public class GenericDelegator implements
             ModelEntity modelEntityTwo = getModelEntity(modelRelationTwo.getRelEntityName());
 
             GenericHelper helper = getEntityHelper(modelEntity);
-
-            return helper.findByMultiRelation(value, modelRelationOne, modelEntityOne, modelRelationTwo, modelEntityTwo, orderBy);
-        } catch (GenericEntityException e) {
+            List<GenericValue> result = helper.findByMultiRelation(value, modelRelationOne, modelEntityOne, modelRelationTwo, modelEntityTwo, orderBy);
+            TransactionUtil.commit(beganTransaction);
+            return result;
+        } catch (Exception e) {
             String errMsg = "Failure in getMultiRelation operation for entity [" + value.getEntityName() + "]: " + e.toString() + ". Rolling back transaction.";
             Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
+            TransactionUtil.rollback(beganTransaction, errMsg, e);
+            throw new GenericEntityException(e);
         }
     }
 
@@ -2472,6 +2344,7 @@ public class GenericDelegator implements
                 beganTransaction = TransactionUtil.begin();
             }
 
+            // FIXME: Replace DCL code with AtomicReference
             if (sequencer == null) {
                 synchronized (this) {
                     if (sequencer == null) {
@@ -2485,25 +2358,17 @@ public class GenericDelegator implements
             ModelEntity seqModelEntity = this.getModelEntity(seqName);
 
             Long newSeqId = sequencer == null ? null : sequencer.getNextSeqId(seqName, staggerMax, seqModelEntity);
-
+            TransactionUtil.commit(beganTransaction);
             return newSeqId;
-        } catch (GenericEntityException e) {
+        } catch (Exception e) {
             String errMsg = "Failure in getNextSeqIdLong operation for seqName [" + seqName + "]: " + e.toString() + ". Rolling back transaction.";
+            Debug.logError(e, errMsg, module);
             try {
-                // only rollback the transaction if we started one...
                 TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "[GenericDelegator] Could not rollback transaction: " + e2.toString(), module);
-            }
-            // rather than logging the problem and returning null, thus hiding the problem, throw an exception
-            throw new GeneralRuntimeException(errMsg, e);
-        } finally {
-            try {
-                // only commit the transaction if we started one...
-                TransactionUtil.commit(beganTransaction);
             } catch (GenericTransactionException e1) {
-                Debug.logError(e1, "[GenericDelegator] Could not commit transaction: " + e1.toString(), module);
+                Debug.logError(e1, "Exception thrown while rolling back transaction: ", module);
             }
+            throw new GeneralRuntimeException(errMsg, e);
         }
     }
 

Modified: ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java?rev=1540491&r1=1540490&r2=1540491&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java (original)
+++ ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java Sun Nov 10 16:43:20 2013
@@ -580,7 +580,7 @@ public class EntityTestSuite extends Ent
         delegator.create(testValue);
         TransactionUtil.rollback(transBegin, null, null);
         GenericValue testValueOut = delegator.findOne("Testing", false, "testingId", "rollback-test");
-        assertEquals("Test that transaction rollback removes value: ", testValueOut, null);
+        assertEquals("Test that transaction rollback removes value: ", null, testValueOut);
     }
 
     /*

Modified: ofbiz/branches/release13.07/framework/webtools/webapp/webtools/entity/ModelInduceFromDb.jsp
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/webtools/webapp/webtools/entity/ModelInduceFromDb.jsp?rev=1540491&r1=1540490&r2=1540491&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/webtools/webapp/webtools/entity/ModelInduceFromDb.jsp (original)
+++ ofbiz/branches/release13.07/framework/webtools/webapp/webtools/entity/ModelInduceFromDb.jsp Sun Nov 10 16:43:20 2013
@@ -66,7 +66,6 @@ ERRORS:
         String author = "None";
         String version = "1.0";
 %><?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE entitymodel PUBLIC "-//OFBiz//DTD Entity Model//EN" "http://ofbiz.apache.org/dtds/entitymodel.dtd">
 <!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
@@ -86,7 +85,8 @@ specific language governing permissions 
 under the License.
 -->
 
-<entitymodel>
+<entitymodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/entitymodel.xsd">
   <!-- ========================================================= -->
   <!-- ======================== Defaults ======================= -->
   <!-- ========================================================= -->
@@ -123,8 +123,7 @@ under the License.
     ModelField field = fieldIterator.next();%>
       <field name="<%=field.getName()%>"<%if(!field.getColName().equals(ModelUtil.javaNameToDbName(field.getName()))){
       %> col-name="<%=field.getColName()%>"<%}%> type="<%=field.getType()%>"><%
-    for (int v = 0; v<field.getValidatorsSize(); v++) {
-      String valName = (String) field.getValidator(v);
+    for (String valName : field.getValidators()) {
       %><validate name="<%=valName%>"/><%
     }%></field><%
   }
@@ -137,7 +136,7 @@ under the License.
     for (int r = 0; r < entity.getRelationsSize(); r++) {
       ModelRelation relation = entity.getRelation(r);%>
       <relation type="<%=relation.getType()%>"<%if(relation.getTitle().length() > 0){%> title="<%=relation.getTitle()%>"<%}
-              %> rel-entity-name="<%=relation.getRelEntityName()%>"><%for(int km=0; km<relation.getKeyMapsSize(); km++){ ModelKeyMap keyMap = relation.getKeyMap(km);%>
+              %> rel-entity-name="<%=relation.getRelEntityName()%>"><%for(ModelKeyMap keyMap : relation.getKeyMaps()){ %>
         <key-map field-name="<%=keyMap.getFieldName()%>"<%if(!keyMap.getFieldName().equals(keyMap.getRelFieldName())){%> rel-field-name="<%=keyMap.getRelFieldName()%>"<%}%> /><%}%>
       </relation><%
     }