关于datamanager的使用

最近学习cuba的使用,按照手册上实验各个模块的使用。按照DataManager那部分的介绍,写了一个小例子但是报错了。代码如下:下面是调用部分的代码。

public class Piechart extends Screen {
    @Inject
    private DataManager dataManager;

    @Inject
    private PieChart pie3Chart;

    @Subscribe
    private void onBeforeShow(BeforeShowEvent event) {
        List<KeyValueEntity> list = dataManager.loadValues(
                "select e.deviceType.name ,count(e.deviceType)  from serviceproject_Device e group by e.deviceType"
        ).properties("deviceType","amount")
                .list();
        for (KeyValueEntity keyValueEntity:list){
            pie3Chart.addData(MapDataItem.of("key",keyValueEntity.getValue("deviceType"),"value",keyValueEntity.getValue("amount")));
        }
    }
}

Device跟DeviceType的代码如下:

public class Device extends StandardEntity {
    private static final long serialVersionUID = 4662348129622561325L;

    @Lookup(type = LookupType.DROPDOWN,actions = {"open"})
    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "device_type_id")
    protected DeviceType deviceType;

    @Lookup(type = LookupType.DROPDOWN,actions = {"open"})
    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "device_model_id")
    protected DeviceModel deviceModel;

    @Lookup(type = LookupType.DROPDOWN,actions = {"open"})
    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "manufacture_id")
    protected Manufacture manufacture;

    @Lookup(type = LookupType.DROPDOWN,actions = {"open"})
    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "supplier_id")
    protected Supplier supplier;

    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "campus_id")
    protected UniversityCampus campus;

    @Column(name = "purchase_date")
    protected Date purchaseDate;

    @Column(name = "on_date")
    protected Date onDate;

    @Column(name = "life_time")
    protected String lifeTime;

    @Lookup(type = LookupType.DROPDOWN,actions = {"open"})
    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "classroom_id")
    protected Classroom classroom;

    @Column(name = "memo")
    protected String memo;
}

DeviceType:

public class DeviceType extends StandardEntity {
    private static final long serialVersionUID = -5225141906533126354L;

    @Column(name = "name")
    protected String name;

    @Column(name = "root")
    protected Boolean root;


    @Lookup(type = LookupType.DROPDOWN,actions = {"open"})
    @ManyToOne(fetch = FetchType.LAZY,optional = true)
    @JoinColumn(name = "parent_id")
    protected DeviceType parentType;
}

调用的时候出现如下错误:

java.lang.NullPointerException
	at com.haulmont.cuba.core.app.RdbmsStore.isEntityAttrViewPermitted(RdbmsStore.java:945)
	at com.haulmont.cuba.core.app.RdbmsStore.getNotPermittedSelectIndexes(RdbmsStore.java:971)
	at com.haulmont.cuba.core.app.RdbmsStore.loadValues(RdbmsStore.java:624)
	at com.haulmont.cuba.core.app.DataManagerBean.loadValues(DataManagerBean.java:254)
	at com.haulmont.cuba.core.app.DataServiceBean.loadValues(DataServiceBean.java:66)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	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:116)
	at sun.reflect.GeneratedMethodAccessor125.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.$Proxy198.loadValues(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	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.$Proxy34.loadValues(Unknown Source)
	at com.haulmont.cuba.client.sys.DataManagerClientImpl.loadValues(DataManagerClientImpl.java:146)
	at com.haulmont.cuba.core.global.FluentValuesLoader.list(FluentValuesLoader.java:47)
	at com.vcube.serviceproject.web.charts.Piechart.onBeforeShow(Piechart.java:31)
	at com.haulmont.bali.events.EventHub.publish(EventHub.java:170)
	at com.haulmont.cuba.gui.screen.Screen.fireEvent(Screen.java:128)
	at com.haulmont.cuba.gui.screen.UiControllerUtils.fireEvent(UiControllerUtils.java:60)
	at com.haulmont.cuba.web.sys.WebScreens.show(WebScreens.java:435)
	at com.haulmont.cuba.web.sys.WebScreens.showFromNavigation(WebScreens.java:543)
	at com.haulmont.cuba.gui.config.MenuItemCommands$ScreenCommand.run(MenuItemCommands.java:327)
	at com.haulmont.cuba.web.sys.SideMenuBuilder$MenuCommandExecutor.accept(SideMenuBuilder.java:264)
	at com.haulmont.cuba.web.sys.SideMenuBuilder$MenuCommandExecutor.accept(SideMenuBuilder.java:249)
	at com.haulmont.cuba.web.gui.components.mainwindow.WebSideMenu$MenuItemImpl.menuSelected(WebSideMenu.java:569)
	at com.haulmont.cuba.web.widgets.CubaSideMenu$1.menuItemTriggered(CubaSideMenu.java:90)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:431)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:396)
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260)
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1577)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107)
	at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73)
	at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

Platform 版本是多少

用的最新版本, ext.cubaVersion = ‘7.1.0.BETA3’

你好,
能不能提供一个能复现这个问题的小项目?

压缩文件中是应用,请查看。cubademo.zip (281.5 KB)

初步判断这是一个bug,我们已反馈此问题,你可以关注一下这个帖子:

11个帖子被分离到新主题国内的用户汉化的问题怎么解决

已确认是Bug, 下一版本会修复。
https://github.com/cuba-platform/cuba/issues/2409