details: https://code.openbravo.com/erp/devel/pi/rev/978a3dc1d8c3
changeset: 17726:978a3dc1d8c3
user: Augusto Mauch <augusto.mauch <at> openbravo.com>
date: Tue Aug 21 10:05:02 2012 +0200
summary: Fixes issue 21229: Child records can be deleted
If the child tab belongs to the same table than its parent tab, it was not
possible to delete records from the child tab. This has been fixed by deleting
the record in a separate transaction.
diffstat:
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
| 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diffs (31 lines):
diff -r 6431b810b73f -r 978a3dc1d8c3
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
---
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
Tue Aug 21 09:50:36 2012 +0200
+++
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
Tue Aug 21 10:05:02 2012 +0200
@@ -347,12 +347,11 @@
if (entityName == null) {
return JsonUtils.convertExceptionToJson(new IllegalStateException("No
entityName parameter"));
}
- final BaseOBObject bob = OBDal.getInstance().get(entityName, id);
+ BaseOBObject bob = OBDal.getInstance().get(entityName, id);
if (bob != null) {
try {
// create the result info before deleting to prevent Hibernate errors
-
final DataToJsonConverter toJsonConverter =
OBProvider.getInstance().get(
DataToJsonConverter.class);
final List<JSONObject> jsonObjects =
toJsonConverter.toJsonObjects(Collections
@@ -362,7 +361,13 @@
jsonResponse.put(JsonConstants.RESPONSE_STATUS,
JsonConstants.RPCREQUEST_STATUS_SUCCESS);
jsonResponse.put(JsonConstants.RESPONSE_DATA, new
JSONArray(jsonObjects));
jsonResult.put(JsonConstants.RESPONSE_RESPONSE, jsonResponse);
+ OBDal.getInstance().commitAndClose();
+ // now do the real delete in a separate transaction
+ // to prevent side effects that a child can not be deleted
+ // from its parent
+ // https://issues.openbravo.com/view.php?id=21229
+ bob = OBDal.getInstance().get(entityName, id);
OBDal.getInstance().remove(bob);
OBDal.getInstance().commitAndClose();
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits