Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0009640Openbravo ERP00. Application dictionarypublic2009-06-25 16:072010-10-30 11:24
FrancescoFinamore 
mtaal 
normalminorhave not tried
closedfixed 
20rPath Linux
2.50MP1 
 
Core
No
0009640: Table Validation on View
I have create a reference with type Table Validation based on a view :
The view is :
CREATE OR REPLACE VIEW it_c_orderlinedetail_v AS
 SELECT ord.ad_client_id, ord.ad_org_id, ord.c_order_id, ord.documentno, ord.dateordered, ord.c_bpartner_id, ad_column_identifier_std('c_bpartner'::character varying, to_char(ord.c_bpartner_id)) AS bpartner_name, ordln.c_orderline_id, ordln.isactive, ordln.line, (((((ord.documentno::text || ' - '::text) || substr(to_char(ord.dateordered)::text, 1, 10)) || ' - '::text) || ordln.line) || ' - '::text) || ad_column_identifier_std('c_bpartner'::character varying, to_char(ord.c_bpartner_id))::text AS name
   FROM c_order ord
   LEFT JOIN c_orderline ordln ON ord.c_order_id::text = ordln.c_order_id::text
  ORDER BY (((((ord.documentno::text || ' - '::text) || substr(to_char(ord.dateordered)::text, 1, 10)) || ' - '::text) || ordln.line) || ' - '::text) || ad_column_identifier_std('c_bpartner'::character varying, to_char(ord.c_bpartner_id))::text;

when i put this reference on a column the compile goes ok, but when i start tomcat the application crashes and give the error :
java.lang.NullPointerException
25-giu-2009 15.50.53 org.apache.catalina.core.StandardContext listenerStart
GRAVE: Exception sending context initialized event to listener instance of class org.openbravo.dal.core.DalContextListener
org.openbravo.base.exception.OBException: java.lang.NullPointerException
    at org.openbravo.base.model.ModelProvider.refresh(ModelProvider.java:114)
    at org.openbravo.dal.core.DalLayerInitializer.initialize(DalLayerInitializer.java:65)
    at org.openbravo.dal.core.DalContextListener.contextInitialized(DalContextListener.java:80)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NullPointerException
    at org.openbravo.base.model.Property.setReferencedProperty(Property.java:266)
    at org.openbravo.base.model.ModelProvider.setReferenceProperties(ModelProvider.java:377)
    at org.openbravo.base.model.ModelProvider.initialize(ModelProvider.java:209)
    at org.openbravo.base.model.ModelProvider.getModel(ModelProvider.java:127)
    at org.openbravo.base.model.ModelProvider.refresh(ModelProvider.java:111)
    ... 17 more
    at org.openbravo.base.model.Property.setReferencedProperty(Property.java:266)
    at org.openbravo.base.model.ModelProvider.setReferenceProperties(ModelProvider.java:377)
    at org.openbravo.base.model.ModelProvider.initialize(ModelProvider.java:209)
    at org.openbravo.base.model.ModelProvider.getModel(ModelProvider.java:127)
    at org.openbravo.base.model.ModelProvider.refresh(ModelProvider.java:111)
    at org.openbravo.dal.core.DalLayerInitializer.initialize(DalLayerInitializer.java:65)
    at org.openbravo.dal.core.DalContextListener.contextInitialized(DalContextListener.java:80)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
25-giu-2009 15.50.54 org.apache.catalina.core.StandardContext start
GRAVE: Error listenerStart
25-giu-2009 15.50.54 org.apache.catalina.core.StandardContext start
GRAVE: Context [/openbravo] startup failed due to previous errors
25-giu-2009 15.50.54 org.apache.catalina.session.StandardManager stop
GRAVE: Exception unloading sessions to persistent storage
java.lang.NullPointerException
    at org.openbravo.base.secureApp.OrgTreeNode.writeObject(OrgTreeNode.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.ArrayList.writeObject(ArrayList.java:570)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1517)
    at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:959)
    at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:517)
    at org.apache.catalina.session.StandardManager.unload(StandardManager.java:463)
    at org.apache.catalina.session.StandardManager.stop(StandardManager.java:667)
    at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4519)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4387)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
 
1) Create the view :
CREATE OR REPLACE VIEW it_c_orderlinedetail_v AS
 SELECT ord.ad_client_id, ord.ad_org_id, ord.c_order_id, ord.documentno, ord.dateordered, ord.c_bpartner_id, ad_column_identifier_std('c_bpartner'::character varying, to_char(ord.c_bpartner_id)) AS bpartner_name, ordln.c_orderline_id, ordln.isactive, ordln.line, (((((ord.documentno::text || ' - '::text) || substr(to_char(ord.dateordered)::text, 1, 10)) || ' - '::text) || ordln.line) || ' - '::text) || ad_column_identifier_std('c_bpartner'::character varying, to_char(ord.c_bpartner_id))::text AS name
   FROM c_order ord
   LEFT JOIN c_orderline ordln ON ord.c_order_id::text = ordln.c_order_id::text
  ORDER BY (((((ord.documentno::text || ' - '::text) || substr(to_char(ord.dateordered)::text, 1, 10)) || ' - '::text) || ordln.line) || ' - '::text) || ad_column_identifier_std('c_bpartner'::character varying, to_char(ord.c_bpartner_id))::text;
2) Create on A.D. the table it_c_orderlinedetail_v (and columns) linked this view with Window = Sales Order
and Po Window=Purchase Order
3) Create a reference it_c_orderlinedetail_v with Type=Table and put on Table Reference tab the table create in the step 2 , the key = C_orderline_id and displayedcolumn = Name
4) Add on c_orderline a field it_rif_id with reference=Table and Reference Search Key = it_c_orderlinedetail_v (created in the step 3)
5) compile window and build the project
6) Start tomcat and it crashes ..
dev-platform-quick-wins
depends on defect 0014636pi closed mtaal Support database views defined in the AD in the Data Access Layer 
Issue History
2009-06-25 16:07FrancescoFinamoreNew Issue
2009-06-25 16:07FrancescoFinamoreAssigned To => rafaroda
2009-06-30 20:44psarobeStatusnew => scheduled
2009-06-30 20:44psarobeAssigned Torafaroda => mtaal
2009-06-30 20:44psarobefix_in_branch => pi
2010-09-21 16:29mtaalRelationship addeddepends on 0014636
2010-09-25 11:27hgbotCheckin
2010-09-25 11:27hgbotNote Added: 0031357
2010-09-25 11:27hgbotStatusscheduled => resolved
2010-09-25 11:27hgbotResolutionopen => fixed
2010-09-25 11:27hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/d61bca59af84c289ad12a3f124432ef0f8fe33df [^]
2010-09-27 17:09rafarodaTag Attached: dev-platform-quick-wins
2010-09-29 11:57hudsonbotCheckin
2010-09-29 11:57hudsonbotNote Added: 0031467
2010-10-21 12:53marvintmNote Added: 0032056
2010-10-21 12:53marvintmStatusresolved => closed
2010-10-30 11:24anonymoussf_bug_id0 => 3098723

Notes
(0031357)
hgbot   
2010-09-25 11:27   
Repository: erp/devel/pi
Changeset: d61bca59af84c289ad12a3f124432ef0f8fe33df
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Sat Sep 25 11:26:10 2010 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/d61bca59af84c289ad12a3f124432ef0f8fe33df [^]

Fixes issue 14636: Support database views defined in the AD in the Data Access Layer, Fixes issue 9640: Table Validation on View

---
M src-test/org/openbravo/test/AllAntTaskTests.java
M src/org/openbravo/base/model/Column.java
M src/org/openbravo/base/model/ModelProvider.java
A src-test/org/openbravo/test/dal/ViewTest.java
---
(0031467)
hudsonbot   
2010-09-29 11:57   
A changeset related to this issue has been promoted to main after passing a series of tests and an OBX has been generated:

Changeset: http://code.openbravo.com/erp/devel/main/rev/d61bca59af84 [^]
Merge Changeset: http://code.openbravo.com/erp/devel/main/rev/51c2c2967221 [^]
Tests: http://builds.openbravo.com/view/int/ [^]
OBX: http://builds.openbravo.com/erp/core/obx/OpenbravoERP-2.50CI.18452.obx [^]
(0032056)
marvintm   
2010-10-21 12:53   
DAL now supports views, so this case will work from now on. However, it's necessary to remark that for views to work on DAL, they need to provide a single primary key column.