Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Summary request on jpa datasource failed

    I have a jpa datasource based listgrid which has server-side summarization (http://www.smartclient.com/smartgwte...Summaries.html). When filter the listgrid the server side throw a "node to traverse cannot be null!" exception.


    I've created the following servlet testcase.

    Version: SmartGWT 5.0p build: 01/10/2015 Eval

    County.java
    Code:
    @Entity
    public class County {
    	
    	@Id
    	@GeneratedValue
    	private Integer id;
    	
    	private String name;
    	
    	private Integer population;
    
    // .. getters and setters
    }
    county.ds.xml
    Code:
    <DataSource  
        ID="county"  
        serverType="jpa"  
        beanClassName="com.pt.aop.model.County"
    >
        <fields>  
            <field name="id" primaryKey="true" type="sequence" hidden="true"/>
            <field name="name" type="text"/>
            <field name="population" type="integer"/>
        </fields>
    </DataSource>
    TestServlet.java
    Code:
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.HashMap;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.isomorphic.datasource.DSRequest;
    import com.isomorphic.datasource.DSResponse;
    import com.isomorphic.datasource.SummaryFunctionType;
    
    @SuppressWarnings("serial")
    public class TestServlet extends HttpServlet {
    	
    	@Override
    	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    		resp.setContentType("text/html");
    		
    		DSRequest dsRequest = new DSRequest("county", "fetch");
    	    dsRequest.setSummaryFunctions(new HashMap<String, SummaryFunctionType>() {{
    	    	put("population", SummaryFunctionType.SUM);
    	    }});
    	    try {
    	    	// any criteria cause: "node to traverse cannot be null" error
    			dsRequest.addToCriteria("name", "Hazard");
    			DSResponse dsResponse = dsRequest.execute();
    			PrintWriter out = resp.getWriter();
    			out.println("Sum: " + dsResponse.getDataField("population"));
    			
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    }
    Without criteria the dsrequest can executed succesfully.

    Server Log:
    === 2015-01-26 13:16:45,176 [c-19] DEBUG ISCKeyedObjectPool - Borrowing object for 'county'
    === 2015-01-26 13:16:45,176 [c-19] DEBUG PoolableDataSourceFactory - Activated DataSource 6 of type 'county'
    === 2015-01-26 13:16:45,176 [c-19] DEBUG DSRequest - Caching instance 6 of DS 'county' from DSRequest.getDataSource()
    === 2015-01-26 13:16:45,176 [c-19] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2015-01-26 13:16:45,177 [c-19] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2015-01-26 13:16:45,177 [c-19] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2015-01-26 13:16:45,177 [c-19] DEBUG JPADataSource - [builtinApplication.null] Creating EntityManager and starting transaction.
    === 2015-01-26 13:16:45,177 [c-19] DEBUG DSRequest - [builtinApplication.null] Clobbering existing FreeResourcesHandler of type 'com.isomorphic.jpa.JPA2DataSource' with a 'com.isomorphic.jpa.JPA2DataSource'
    === 2015-01-26 13:16:45,177 [c-19] DEBUG JPADataSource - [builtinApplication.null] Executing fetch.
    === 2015-01-26 13:16:45,177 [c-19] DEBUG JPADataSource - [builtinApplication.null] Query string: select SUM(_County.population) as population from County _County where (lower(_County.name) = lower(:p0))
    === 2015-01-26 13:16:45,177 [c-19] DEBUG JPADataSource - [builtinApplication.null] Marking transaction for roll back.
    === 2015-01-26 13:16:45,177 [c-19] DEBUG JPADataSource - [builtinApplication.null] Rolling back current transaction.
    === 2015-01-26 13:16:45,178 [c-19] DEBUG JPADataSource - [builtinApplication.null] Got exception while executing. Transaction will be rolled back.
    java.lang.IllegalArgumentException: node to traverse cannot be null!
    at org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:63)
    at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:282)
    at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:184)
    at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
    at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
    at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)
    at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:277)
    at com.isomorphic.jpa.JPADataSource.createQuery(JPADataSource.java:2062)
    at com.isomorphic.jpa.JPADataSource.executeFetch(JPADataSource.java:692)
    at com.isomorphic.datasource.DataSource.execute(DataSource.java:1922)
    at com.isomorphic.jpa.JPADataSource.execute(JPADataSource.java:652)
    at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:726)
    at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658)
    at com.isomorphic.application.AppBase.execute(AppBase.java:491)
    at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2543)
    at com.pt.aop.master.server.TestServlet2.doGet(TestServlet2.java:32)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
    === 2015-01-26 13:16:45,178 [c-19] DEBUG DSRequest - About to free up resources for request of type fetch on DataSource county
    === 2015-01-26 13:16:45,178 [c-19] DEBUG JPADataSource - Releasing entity manager.
    === 2015-01-26 13:16:45,179 [c-19] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 6 of type 'county'
    Last edited by s.csaba; 26 Jan 2015, 04:23.

    #2
    This is fixed now, you may download next nightly build (2015-01-30) and try it out.

    Comment


      #3
      Confirmed, thank you.

      Comment

      Working...
      X