Announcement

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

    Simple criteria problem

    v8.3p_2012-12-12/PowerEdition Deployment (built 2012-12-12)

    I'm trying to SelectOtherItem.setPickListCriteria() and facing two problems:

    1. When i try

    Code:
    Criteria cr = new Criteria();
    cr.addCriteria("rubricatorId", rubId); //Long
    select.setPickListCriteria(cr);
    I get
    Code:
    === 2012-12-13 10:58:47,028 [l0-5] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{
            rubricatorId:318
        },
        operationConfig:{
            dataSource:"rubSections",
            operationType:"fetch",
            textMatchStyle:"startsWith"
        },
        startRow:0,
        endRow:75,
        componentId:"isc_PickListMenu_0",
        appID:"builtinApplication",
        operation:"rubSections_fetch",
        oldValues:{
            rubricatorId:318
        }
    }
    ...
    === 2012-12-13 10:58:47,034 [l0-5] INFO  HibernateDataSource - [builtinApplication.rubSections_fetch] Query string: select _RubSection, parent1 from ru.eurotechnologygroup.etgcrm.server.model.RubSection _RubSection left outer join _RubSection.parent parent1 where (lower(concat(_RubSection.rubricatorId,'')) like lower(:p0) escape '~')
    === 2012-12-13 10:58:47,045 [l0-5] DEBUG HibernateDataSource - [builtinApplication.rubSections_fetch] Parameter p0: [b]318%[/b]
    === 2012-12-13 10:58:47,045 [l0-5] DEBUG SQL - select count(*) as col_0_0_ from rubsection rubsection0_ where lower((rubsection0_.RUBID+'')) like lower(?) escape '~'
    === 2012-12-13 10:58:47,060 [l0-5] DEBUG SQL - select top 75 rubsection0_.RSID as RSID9_0_, rubsection1_.RSID as RSID9_1_, rubsection0_.RSHIDDEN as RSHIDDEN9_0_, rubsection0_.RSNAME as RSNAME9_0_, rubsection0_.RSNAMEADD as RSNAMEADD9_0_, rubsection0_.RSPARENTID as RSPARENTID9_0_, rubsection0_.RUBID as RUBID9_0_, rubsection1_.RSHIDDEN as RSHIDDEN9_1_, rubsection1_.RSNAME as RSNAME9_1_, rubsection1_.RSNAMEADD as RSNAMEADD9_1_, rubsection1_.RSPARENTID as RSPARENTID9_1_, rubsection1_.RUBID as RUBID9_1_ from rubsection rubsection0_ left outer join rubsection rubsection1_ on rubsection0_.RSPARENTID=rubsection1_.RSID where lower((rubsection0_.RUBID+'')) like lower(?) escape '~'
    === 2012-12-13 10:58:47,072 [l0-5] INFO  DSResponse - [builtinApplication.rubSections_fetch] DSResponse: List with 4 items
    You can see that select statement performs LIKE comparison with "318%" value. From my point of view there should not be LIKE-comparison on Long value (it's long in dataSource definition).

    But ok, i'm switching to AdvancedCriteria and facing the problem №2

    2. I try

    Code:
    AdvancedCriteria cr = new AdvancedCriteria();
    cr.addCriteria("rubricatorId", rubId);
    cr.setOperator(OperatorId.EQUALS);
    select.setPickListCriteria(cr);
    and i get in my datasource

    req.getCriteria()
    Code:
    req.getCriteria() = {java.util.HashMap@9730} size = 3
        [0] = {java.util.HashMap$Entry@9734}"criteria" ->  size = 1
            key: java.lang.String = {java.lang.String@9736}"criteria"
            value: java.util.ArrayList = {java.util.ArrayList@9737} size = 1
                [0] = {org.apache.commons.collections.map.LinkedMap@9745} size = 3
                    [0] = {org.apache.commons.collections.map.AbstractLinkedMap$LinkEntry@9748}"_constructor" -> "AdvancedCriteria"
                    [1] = {org.apache.commons.collections.map.AbstractLinkedMap$LinkEntry@9750}"rubricatorId" -> "318"
                    [2] = {org.apache.commons.collections.map.AbstractLinkedMap$LinkEntry@11210}"operator" -> "equals"
        [1] = {java.util.HashMap$Entry@9738}"operator" -> "and"
        [2] = {java.util.HashMap$Entry@9741}"_constructor" -> "AdvancedCriteria"
    That's ok, but

    req.getAdvancedCriteria()
    Code:
    AdvancedCriteria:[and:[null]]
    and

    req.getAdvancedCriteria().getCriteriaAsMap()
    Code:
    java.lang.NullPointerException
    TY.

    #2
    1. you've set textMatchStyle "startsWith" so that's what you got

    2. can you show the server log for the request instead of this other kind of dump? A dump of HashMap keysets is much harder to read and lacks context provided by normal server logs.

    Comment


      #3
      1. Thank you for pointing that to me. Not completely used to framework yet. My fault.

      2. About advanced criteria:

      Code:
      AdvancedCriteria cr = new AdvancedCriteria();
      cr.addCriteria("rubricatorId", rubId);
      cr.setOperator(OperatorId.EQUALS);
      select.setPickListCriteria(cr);
      Code:
      === 2012-12-14 01:23:12,530 [l0-9] DEBUG RPCManager - Request #1 (DSRequest) payload: {
          criteria:{
              operator:"and",
              _constructor:"AdvancedCriteria",
              criteria:[
                  {
                      _constructor:"AdvancedCriteria",
                      rubricatorId:318,
                      operator:"equals"
                  }
              ]
          },
          operationConfig:{
              dataSource:"rubSections",
              operationType:"fetch",
              textMatchStyle:"startsWith"
          },
          startRow:0,
          endRow:75,
          componentId:"isc_PickListMenu_0",
          appID:"builtinApplication",
          operation:"rubSections_fetch",
          oldValues:{
              operator:"and",
              _constructor:"AdvancedCriteria",
              criteria:[
                  {
                      _constructor:"AdvancedCriteria",
                      rubricatorId:318,
                      operator:"equals"
                  }
              ]
          }
      }
      === 2012-12-14 01:23:12,530 [l0-9] INFO  IDACall - Performing 1 operation(s)
      === 2012-12-14 01:23:12,530 [l0-9] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
      === 2012-12-14 01:23:12,530 [l0-9] DEBUG DeclarativeSecurity - DataSource rubSections is not in the pre-checked list, processing...
      === 2012-12-14 01:23:12,530 [l0-9] DEBUG AppBase - [builtinApplication.rubSections_fetch] No userTypes defined, allowing anyone access to all operations for this application
      === 2012-12-14 01:23:12,530 [l0-9] DEBUG AppBase - [builtinApplication.rubSections_fetch] No public zero-argument method named '_rubSections_fetch' found, performing generic datasource operation
      === 2012-12-14 01:23:12,530 [l0-9] WARN  HibernateTransaction - Attempted to close session for null transaction.
      === 2012-12-14 01:23:12,531 [l0-9] WARN  RequestContext - dsRequest.execute() failed: 
      java.lang.NullPointerException
      	at com.isomorphic.criteria.LogicalOperator.convertToMap(LogicalOperator.java:63)
      	at com.isomorphic.criteria.AdvancedCriteria.getCriteriaAsMap(AdvancedCriteria.java:250)
      	at ru.eurotechnologygroup.etgcrm.server.dmi.EtgHibernateDataSource.executeFetch(EtgHibernateDataSource.java:47)
      	at ru.eurotechnologygroup.etgcrm.server.dmi.RubSectionDataSource.executeFetch(RubSectionDataSource.java:25)
      	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1368)
      	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:2017)
      	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:216)
      	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:173)
      	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:138)
      	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:74)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
      	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
      	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
      	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
      	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
      	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
      	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
      	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.Server.handle(Server.java:324)
      	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
      	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
      	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
      === 2012-12-14 01:23:12,536 [l0-9] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2012-12-14 01:23:12,540 [l0-9] DEBUG RPCManager - non-DMI response, dropExtraFields: false
      Exception occures calling

      Code:
      @Override
          public DSResponse executeFetch(DSRequest req) throws Exception
          {
              AdvancedCriteria criteria = req.getAdvancedCriteria();
              Map criteriaAsMap = criteria.getCriteriaAsMap();
      ...
      }
      in DataSource implementation.

      At the same time

      Code:
      AdvancedCriteria cr = new AdvancedCriteria(OperatorId.AND, new Criterion[]{new Criterion("rubricatorId", OperatorId.EQUALS, rubId)});
      works fine and produces a little different criteria
      Code:
      criteria:{
              operator:"and",
              _constructor:"AdvancedCriteria",
              criteria:[
                  {
                      fieldName:"rubricatorId",
                      operator:"equals",
                      value:318
                  }
              ]
          },

      Comment


        #4
        Ah, OK, this series of calls:

        Code:
        AdvancedCriteria cr = new AdvancedCriteria();
        cr.addCriteria("rubricatorId", rubId);
        cr.setOperator(OperatorId.EQUALS);
        .. was unexpected - you're actually calling a superclass method Criteria.addCriteria() - and is actually more verbose than using the convenience constructors for AdvancedCriteria.

        It should work anyway, so we'll get it fixed, but use the convenience constructors instead for now.

        Comment

        Working...
        X