Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033515Openbravo ERPA. Platformpublic2016-07-20 16:442016-07-26 09:29
Sanjota 
alostale 
highminoralways
closedfixed 
5
 
3.0PR16Q4 
caristu
No
Core
No
0033515: NPE in AdvancedQueryBuilder with joinAssociatedEntities if entity has computed columns
AdvancedQueryBuilder has a joinAssociatedEntities which creates the query including joins for all many-to-one properties. If the entity being queried includes computed columns, a NPE is thrown.

Note this does not affect standard behavior, as the default value for joinAssociatedEntities is always null when invoked from UI.
Whenever we use advanced query builder for retrieving records from the table,
if the table has computed column(as property) then property.getTargetEntity() is null and
KernelUtils.hasNullableIdentifierProperties(property.getTargetEntity()) will through null pointer exception.

Example Scenario : Following are steps for one of the scenario faced
1) Install module org.openbravo.authorize.net to pi environment.
2) Test IssuesTest.java i.e Run as Junit.
3) Test - test20733() present in IssuesTest.java fails
Giving details of the stack trace for Null pointer exception as
 java.lang.NullPointerException
    at org.openbravo.client.kernel.KernelUtils.hasNullableIdentifierProperties(KernelUtils.java:520)
    at org.openbravo.service.json.AdvancedQueryBuilder$JoinDefinition.getJoinStatement(AdvancedQueryBuilder.java:1838)
    at org.openbravo.service.json.AdvancedQueryBuilder.getJoinClause(AdvancedQueryBuilder.java:1349)
    at org.openbravo.service.json.DataEntityQueryService.getWhereClause(DataEntityQueryService.java:120)
    at org.openbravo.service.json.DataEntityQueryService.buildOBQuery(DataEntityQueryService.java:127)
    at org.openbravo.service.json.DataEntityQueryService.list(DataEntityQueryService.java:106)
    at org.openbravo.test.dal.IssuesTest.test20733(IssuesTest.java:818)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
No tags attached.
diff 33515.diff (1,463) 2016-07-20 16:52
https://issues.openbravo.com/file_download.php?file_id=9639&type=bug
Issue History
2016-07-20 16:44SanjotaNew Issue
2016-07-20 16:44SanjotaAssigned To => platform
2016-07-20 16:44SanjotaOBNetwork customer => No
2016-07-20 16:44SanjotaModules => Core
2016-07-20 16:44SanjotaTriggers an Emergency Pack => No
2016-07-20 16:45SanjotaSeveritymajor => minor
2016-07-20 16:52aferrazFile Added: 33515.diff
2016-07-21 09:08alostaleSummaryNullpointer exception in KernelUtils.hasNullableIdentifierProperties() present in KernelUtils.java => NPE in AdvancedQueryBuilder with joinAssociatedEntities if entity has computed columns
2016-07-21 09:08alostaleDescription Updatedbug_revision_view_page.php?rev_id=12717#r12717
2016-07-21 09:12alostaleReview Assigned To => caristu
2016-07-21 09:12alostaleAssigned Toplatform => alostale
2016-07-21 09:13hgbotCheckin
2016-07-21 09:13hgbotNote Added: 0088607
2016-07-21 09:13hgbotStatusnew => resolved
2016-07-21 09:13hgbotResolutionopen => fixed
2016-07-21 09:13hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/b7bce66ab19202bc3cad0ca6070c6d5d21c6fed8 [^]
2016-07-26 09:29caristuNote Added: 0088657
2016-07-26 09:29caristuStatusresolved => closed
2016-07-26 09:29caristuFixed in Version => 3.0PR16Q4

Notes
(0088607)
hgbot   
2016-07-21 09:13   
Repository: erp/devel/pi
Changeset: b7bce66ab19202bc3cad0ca6070c6d5d21c6fed8
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Jul 21 09:12:30 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/b7bce66ab19202bc3cad0ca6070c6d5d21c6fed8 [^]

fixed 33515: NPE in AQB with associated entities if entity has computed columns

  When AdvancedQueryBuilder was used with the joinAssociatedEntities property set
  to true and the queried entity included computed columns, a NPE was trhown.

  Fixed by treating computed column property as an special case forcing always
  a left join for it.

---
M modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
---
(0088657)
caristu   
2016-07-26 09:29   
Code review + testing OK.

Tested using steps to reproduce in pi@c1dff2b0991a