Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036391Openbravo ERPA. Platformpublic2017-07-03 18:112017-09-21 16:49
ngarcia 
alostale 
highminoralways
closedfixed 
5
 
3.0PR17Q4 
caristu
Core
No
0036391: inconsistent behavior of OBDal.get by entity name + id when trying to populate a proxy by entity name + id
When OBDal.get is used to get a record which ID does not exist in DB, it returns null.

Previous statement is true as far as there was not a proxy for the same object in Hibernate cache, in this case an ObjectNotFoundException is thrown.

1. BusinessPartner bpProxy = (BusinessPartner) OBDal.getInstance().getProxy("BusinessPartner", "dummyId");
2. final BusinessPartner bpartner = (BusinessPartner) OBDal.getInstance().get("BusinessPartner", "dummyId");

Then, the query breaks if the object does not exist in DB.
Add catch clause in OBDal class in get method:
  public BaseOBObject get(String entityName, Object id) {
    checkReadAccess(entityName);
    try {
      return SessionHandler.getInstance().find(entityName, id);
    } catch (ObjectNotFoundException ignore) {
      return null;
    }
  }
No tags attached.
related to defect 0034657 closed alostale inconsistent behavior of OBDal.get when trying to get an inexistent record  
Issue History
2017-07-03 18:11ngarciaNew Issue
2017-07-03 18:11ngarciaAssigned To => platform
2017-07-03 18:11ngarciaModules => Core
2017-07-03 18:11ngarciaTriggers an Emergency Pack => No
2017-07-03 18:11ngarciaIssue generated from0034657
2017-07-03 18:12ngarciaIssue Monitored: networkb
2017-07-03 18:13ngarciaRelationship addedrelated to 0034657
2017-07-04 11:17alostaleAssigned Toplatform => alostale
2017-07-04 11:17alostaleReview Assigned To => caristu
2017-07-04 11:18alostaleSummaryinconsistent behavior of OBDal.get when trying to get an inexistent record => inconsistent behavior of OBDal.get by entity name + id when trying to populate a proxy by entity name + id
2017-07-04 11:21hgbotCheckin
2017-07-04 11:21hgbotNote Added: 0097830
2017-07-04 11:21hgbotStatusnew => resolved
2017-07-04 11:21hgbotResolutionopen => fixed
2017-07-04 11:21hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/59f0b694423987416230f272f4164bc6f291c12c [^]
2017-07-04 20:09caristuNote Added: 0097850
2017-07-04 20:09caristuStatusresolved => closed
2017-07-04 20:09caristuFixed in Version => 3.0PR17Q4
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099232

Notes
(0097830)
hgbot   
2017-07-04 11:21   
Repository: erp/devel/pi
Changeset: 59f0b694423987416230f272f4164bc6f291c12c
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Tue Jul 04 11:16:39 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/59f0b694423987416230f272f4164bc6f291c12c [^]

fixed bug 36391: inconsistent behavior of OBDal.get getting an inexistent row

  When getting a DAL object by entity name + id that's already proxied in cache
  it throws a ObjectNotFoundException if it does not exist in DB. Standard API
  for OBDal.get methods is to return null in this case.

---
M src-test/src/org/openbravo/test/dal/DalTest.java
M src/org/openbravo/dal/service/OBDal.java
---
(0097850)
caristu   
2017-07-04 20:09   
Code reviewed + tested OK
(0099232)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test