Problem with value source and multiple entities

Hi, I am trying to create a value source to retrieve joined entities over a specified date.


<valueGroupDatasource id="productDs">
	<query>
		<![CDATA[SELECT p, pp FROM my$Product p JOIN my$ProductPrice pp WHERE pp.product = p]]>
		<filter>
			<and>
				<c>pp.valuation = :component$valuationDay</c>
			</and>
		</filter>
	</query>
	<properties idProperty="product">
		<property name="product" class="Product"/>
		<property name="price" class="ProductPrice"/>
	</properties>
</valueGroupDatasource>

I keep getting this error:


java.lang.NullPointerException: null
	at com.haulmont.cuba.core.app.RdbmsStore.isEntityAttrViewPermitted(RdbmsStore.java:722) ~[cuba-core-6.5.0.jar:6.5.0]
	at com.haulmont.cuba.core.app.RdbmsStore.getNotPermittedSelectIndexes(RdbmsStore.java:742) ~[cuba-core-6.5.0.jar:6.5.0]
	at com.haulmont.cuba.core.app.RdbmsStore.loadValues(RdbmsStore.java:431) ~[cuba-core-6.5.0.jar:6.5.0]
	at com.haulmont.cuba.core.app.DataManagerBean.loadValues(DataManagerBean.java:253) ~[cuba-core-6.5.0.jar:6.5.0]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
	at com.haulmont.cuba.core.app.DataManagerBean$SecureDataManagerInvocationHandler.invoke(DataManagerBean.java:355) ~[cuba-core-6.5.0.jar:6.5.0]
	at com.sun.proxy.$Proxy361.loadValues(Unknown Source) ~[na:na]
	at com.haulmont.cuba.core.app.DataServiceBean.loadValues(DataServiceBean.java:61) ~[cuba-core-6.5.0.jar:6.5.0]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]

When trying to debug through the internals, I discovered the problem is probably here (RdbmsStore.java around 742):


for (QueryParser.QueryPath path : queryParser.getQueryPaths()) {
                if (path.isSelectedPath()) {
                    MetaClass metaClass = metadata.getClassNN(path.getEntityName());
                    if (!isEntityAttrViewPermitted(metaClass.getPropertyPath(path.getPropertyPath()))) {
                        indexes.add(index);
                    }
                    index++;
                }
            }

Where path.getPropertyPath() returns “p” for queryPath “p” when variable name is “p”. This does not decode property though and thus it is not surprising, that it could find one. This denotes the whole entity being selected. I am a bit surprised that the valueSource does actually work in different scenarios (this is the first time we used valueSource on our project).

Are we using it in a wrong way?

Hi Jan,

Thank you for reporting the problem. I have created YouTrack issue. We’ll fix it in the next bugfix release.

How do you use ValueDatasource? As a workaround, you can select only attributes of Product and ProductPrice.

Hi Jan,
The problem is fixed in the platform version 6.5.1.

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/PL-9026