我正在使用来自lazyquerycontainer插件的EntityContainer 类。顾名思义,它支持延迟加载。它只是工作:)
一些示例代码:
resultsTable = new Table();
resultsTable.setSelectable(true);
resultsTable.setCaption("JpaQuery");
resultsTable.setPageLength(40);
resultsTable.setImmediate(true);
resultsTable.setEditable(false);
resultsTable.setWriteThrough(true);
container = new EntityContainer<Call>(em, false, true, true, Call.class, 100, new Object[] {"imsi"}, new boolean[] {true});
container.addContainerProperty(LazyQueryView.PROPERTY_ID_ITEM_STATUS, QueryItemStatus.class, QueryItemStatus.None, true, false);
container.addContainerProperty("startTime", Date.class, null, true, true);
container.addContainerProperty("stopTime", Date.class, null, true, true);
container.addContainerProperty("imsi", String.class, null, false, true);
container.addContainerProperty("imei", String.class, null, false, true);
container.addContainerProperty("callType", Integer.class, null, true, true);
container.addContainerProperty("cdpn", String.class, null, true, true);
container.addContainerProperty("cgpn", String.class, null, true, true);
container.addContainerProperty("status", Integer.class, null, true, true);
container.addContainerProperty("mmRelCause", Integer.class, null, true, true);
container.addContainerProperty("rrRelCause", Integer.class, null, true, true);
resultsTable.setContainerDataSource(container);
resultsTable.setVisibleColumns(new String[] {"startTime" , "stopTime" , "imsi", "imei", "callType" , "cdpn", "cgpn", "status", "mmRelCause" , "rrRelCause" });
resultsTable.setColumnHeaders(new String[] {"Start time", "Stop time", "IMSI", "IMEI", "Call Type", "CDPN", "CGPN", "Status", "MM Release Cause", "RR Release Cause"});
resultsTable.setColumnCollapsingAllowed(true);
resultsTable.setColumnCollapsed("mmRelCause", true);
resultsTable.setColumnCollapsed("rrRelCause", true);
要基于 JQL 过滤数据,您可以执行filter
传递过滤器字符串和绑定变量映射的方法。
...
whereParameters.put("stopTimeFrom", filterParams.getStopTimeFrom());
where = "e.startTime >= :stopTimeFrom";
...
container.filter(where, whereParameters);
如果你更喜欢 Criteria API,你可以使用criteriacontainer。