I am noticing another loss of RAD tool which is in data loading.
In the legacy screen, the following code in Ds definition at screen design level would have been enough without any code in the controller.
select e from erp$Employee e
where e.joinDateActual is null and e.manager.id = :ds$managersDs.id
However, according to the user guide in the new platform version 7+, there are several more lines of code needs to be written in the controller which is not the impression I had as the new version is supposed to be more clean and transparent.
Code at screen level:
select e from erp$Employee e
where e.joinDateActual is null and e.manager = :manager
java.lang.IllegalStateException: Query argument allowanceType not found in the list of parameters provided during query execution.
at org.eclipse.persistence.internal.jpa.QueryImpl.processParameters(QueryImpl.java:592)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:183)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:482)
at com.haulmont.cuba.core.sys.QueryImpl.getResultFromCache(QueryImpl.java:715)
at com.haulmont.cuba.core.sys.QueryImpl.getResultList(QueryImpl.java:372)
at com.haulmont.cuba.core.app.RdbmsStore.executeQuery(RdbmsStore.java:756)
at com.haulmont.cuba.core.app.RdbmsStore.getResultList(RdbmsStore.java:664)
at com.haulmont.cuba.core.app.RdbmsStore.loadList(RdbmsStore.java:225)
at com.haulmont.cuba.core.app.DataManagerBean.loadList(DataManagerBean.java:74)
at com.haulmont.cuba.core.app.DataServiceBean.loadList(DataServiceBean.java:54)
at sun.reflect.GeneratedMethodAccessor367.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:117)
at sun.reflect.GeneratedMethodAccessor272.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy138.loadList(Unknown Source)
at sun.reflect.GeneratedMethodAccessor366.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.haulmont.cuba.core.sys.remoting.LocalServiceInvokerImpl.invoke(LocalServiceInvokerImpl.java:94)
at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.invoke(LocalServiceProxy.java:154)
at com.sun.proxy.$Proxy339.loadList(Unknown Source)
at com.haulmont.cuba.client.sys.DataManagerClientImpl.loadList(DataManagerClientImpl.java:57)
at com.haulmont.cuba.gui.model.impl.CollectionLoaderImpl.load(CollectionLoaderImpl.java:88)
at com.haulmont.cuba.gui.model.impl.ScreenDataImpl.loadAll(ScreenDataImpl.java:79)
at com.haulmont.cuba.web.sys.WebScreens.loadDataBeforeShow(WebScreens.java:536)
at com.haulmont.cuba.web.sys.WebScreens.show(WebScreens.java:424)
at com.haulmont.cuba.gui.screen.Screen.show(Screen.java:309)
at com.haulmont.cuba.gui.actions.list.EditAction.actionPerform(EditAction.java:144)
at com.haulmont.cuba.web.gui.components.WebButton.buttonClicked(WebButton.java:62)
According to your code, allowanceType parameter is assigned only when the entity attribute is changed, so it is not passed initially on screen opening.
Either assign it unconditionally in onBeforeShow or use query conditions to modify the query automatically based on presence of the parameter.
Hi Konstantin
Thanks. Query conditions looks interesting and believe will be useful. If there would have any mark in the user guide for the feature in the new version that would be helpful for quick attention for the users like I missed it until you mentioned.
Another relevant question, when are we going to have option to use a data container data as the filter condition at query level for another data container like we used to have in legacy Studio (e.g. where e.company.id = :ds$companyDs.id)? Eagerly waiting for release of platform v 7.1 where I am expecting it.
@Konstantin
I have tried according to what you indicated in the user guide but didn’t work.
My code:
XML file
<collection id="allowancesDc" class="com.inteacc.erp.entity.pr.Allowance" view="_minimal">
<loader id="allowancesLc">
<query><![CDATA[select e from erp$Allowance e
where e.allowanceType = :allowanceType]]></query>
</loader>
</collection>
java.lang.IllegalStateException: Query argument allowanceType not found in the list of parameters provided during query execution.
at org.eclipse.persistence.internal.jpa.QueryImpl.processParameters(QueryImpl.java:592)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:183)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:482)
at com.haulmont.cuba.core.sys.QueryImpl.getResultFromCache(QueryImpl.java:715)
at com.haulmont.cuba.core.sys.QueryImpl.getResultList(QueryImpl.java:372)
at com.haulmont.cuba.core.app.RdbmsStore.executeQuery(RdbmsStore.java:756)
at com.haulmont.cuba.core.app.RdbmsStore.getResultList(RdbmsStore.java:664)
at com.haulmont.cuba.core.app.RdbmsStore.loadList(RdbmsStore.java:225)
at com.haulmont.cuba.core.app.DataManagerBean.loadList(DataManagerBean.java:74)
at com.haulmont.cuba.core.app.DataServiceBean.loadList(DataServiceBean.java:54)
at sun.reflect.GeneratedMethodAccessor326.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
I did use the condition according to the documentation and will try again.
This process may have some other good use cases though not so straight forward, may we have the legacy Studio feature back that i raised in the beginning please please?
Yes, but it was about linking data components. Your latest problem here is not relevant, as you are refreshing data container depending on some attribute value.
This looks like query is executed before parameter is passed. The use of condition in xml seems like new, I haven’t faced this situation in legacy version and something might be missing while this condition is introduced! Can this use of condition be simplified in the designer to avoid direct update in xml?