Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0034657
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformmajoralways2016-11-30 16:492017-07-03 18:11
ReporterkchoperenaView Statuspublic 
Assigned Toalostale 
PriorityurgentResolutionfixedFixed in Version3.0PR17Q1
StatusclosedFix in branchFixed in SCM revision72cd92b69d62
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tocaristu
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0034657: inconsistent behavior of OBDal.get when trying to get an inexistent record

DescriptionWhen 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.

Steps To Reproduce1. BusinessPartner bpProxy = OBDal.getInstance().getProxy(BusinessPartner.class, "dummyId");
2. final BusinessPartner bpartner = OBDal.getInstance().get(BusinessPartner.class, "dummyId");

Then, the query breaks if the object does not exist in DB.

Workaround: If we use "OBDal.getInstance().getSession().evict(bpProxy);" sentence before make the query, it works succesfully
Proposed SolutionAdd catch clause in OBDal class in get method:
public <T extends Object> T get(Class<T> clazz, Object id) {
    checkReadAccess(clazz);
    try {
      return SessionHandler.getInstance().find(clazz, id);
    } catch (org.hibernate.ObjectNotFoundException e) {
      return null;
    }
  }
TagsNo tags attached.
Attached Filesdiff file icon OBDalPatch.diff [^] (539 bytes) 2016-11-30 16:49 [Show Content]

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0036391 closedalostale inconsistent behavior of OBDal.get by entity name + id when trying to populate a proxy by entity name + id 

-  Notes
(0091980)
hgbot (developer)
2016-12-01 16:11

Repository: erp/devel/pi
Changeset: 72cd92b69d6292e4933c46b43d916ffb900604fc
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Dec 01 16:10:42 2016 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/72cd92b69d6292e4933c46b43d916ffb900604fc [^]

fixed bug 34657: inconsistent behavior of OBDal.get

  OBDal.get behaved inconsistently when trying to obtain an object for an ID that
  is not present in DB:

   -It usually returns null
   -unless there was a proxy for the same object, which thrown an exception

  Fixed by making it to always return null in this case.

---
M src-test/src/org/openbravo/test/dal/DalTest.java
M src/org/openbravo/dal/service/OBDal.java
---
(0092044)
caristu (developer)
2016-12-02 15:40

Code review + testing OK.
(0092680)
hudsonbot (developer)
2016-12-16 18:39

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/dc8bf00badd0 [^]
Maturity status: Test

- Issue History
Date Modified Username Field Change
2016-11-30 16:49 kchoperena New Issue
2016-11-30 16:49 kchoperena Assigned To => alostale
2016-11-30 16:49 kchoperena File Added: OBDalPatch.diff
2016-11-30 16:49 kchoperena Modules => Core
2016-11-30 16:49 kchoperena Triggers an Emergency Pack => No
2016-11-30 17:39 alostale Assigned To alostale => platform
2016-11-30 17:39 alostale Status new => acknowledged
2016-11-30 17:39 alostale Category Y. DBSourceManager => A. Platform
2016-12-01 13:17 alostale Priority normal => urgent
2016-12-01 14:14 alostale Status acknowledged => scheduled
2016-12-01 14:14 alostale Assigned To platform => alostale
2016-12-01 16:06 alostale Summary When we try to make a query of any object that not exist in DB but we have a proxy opened before, the query breaks => inconsistent behavior of OBDal.get when trying to get an inexistent record
2016-12-01 16:06 alostale Description Updated View Revisions
2016-12-01 16:06 alostale Steps to Reproduce Updated View Revisions
2016-12-01 16:06 alostale Review Assigned To => caristu
2016-12-01 16:11 hgbot Checkin
2016-12-01 16:11 hgbot Note Added: 0091980
2016-12-01 16:11 hgbot Status scheduled => resolved
2016-12-01 16:11 hgbot Resolution open => fixed
2016-12-01 16:11 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/72cd92b69d6292e4933c46b43d916ffb900604fc [^]
2016-12-02 15:40 caristu Note Added: 0092044
2016-12-02 15:40 caristu Status resolved => closed
2016-12-02 15:40 caristu Fixed in Version => 3.0PR17Q1
2016-12-16 18:39 hudsonbot Checkin
2016-12-16 18:39 hudsonbot Note Added: 0092680
2017-07-03 18:11 ngarcia Issue cloned 0036391
2017-07-03 18:13 ngarcia Relationship added related to 0036391


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker