5 Replies Latest reply on Oct 21, 2008 12:40 PM by Andre Eugenio

    Problem with order using DataModel

    Jose Miguel Loor Apprentice

      Hi

      I am using a DataModel to retrieve correctly paginated data from my database. This is the code of my GenericDataModel (from wich i extend my actual working beans)

      
      package ec.gov.seguridadciudadana.dts.datamodel;
      
      import java.io.IOException;
      import java.io.Serializable;
      import java.util.ArrayList;
      import java.util.HashMap;
      import java.util.List;
      import java.util.Map;
      
      import javax.faces.application.FacesMessage;
      import javax.faces.context.FacesContext;
      
      import org.ajax4jsf.model.DataVisitor;
      import org.ajax4jsf.model.ExtendedDataModel;
      import org.ajax4jsf.model.Range;
      import org.ajax4jsf.model.SequenceRange;
      
      import ec.gov.seguridadciudadana.dts.model.Identifiable;
      
      /**
       * The Class for Generic data model.
       *
       * @author nDeveloper
       * @version $Revision: 1.4 $
       */
      public abstract class GenericDataModel<T extends Identifiable, ID extends Serializable>
       extends ExtendedDataModel {
      
       /** The Constant TRAMITE_SERVICIO. */
       public static final String TRAMITE_SERVICIO = "TramiteServicioImpl/local";
      
       /** The Constant TRAMITE_NOTIFICACION_SERVICIO. */
       public static final String TRAMITE_NOTIFICACION_SERVICIO = "TramiteNotificacionServicioImpl/local";
      
       /** The list row. */
       public List<T> listRow;
      
       /** The row num. */
       int rowNum = -1;
      
       /** The current id. */
       private ID currentId;
      
       /** The wrapped keys. */
       private List<ID> wrappedKeys;
      
       /** The wrapped data. */
       private Map<ID, T> wrappedData = new HashMap<ID, T>();
      
       /**
       * Gets the row num.
       *
       * @return the row num
       */
       public int getRowNum() {
       return ++rowNum;
       }
      
       /**
       * Gets the count.
       *
       * @return the count
       */
       public abstract Long getCount();
      
       /**
       * Gets the list.
       *
       * @param firstRow the first row
       * @param maxResults the max results
       *
       * @return the list
       */
       public abstract List<T> getList(final Integer firstRow,
       final Integer maxResults);
      
       /**
       * Load list.
       *
       * @param firstRow the first row
       * @param maxResults the max results
       *
       * @return the list< t>
       */
       private List<T> loadList(final Integer firstRow, final Integer maxResults) {
       return listRow = getList(firstRow, maxResults);
       }
      
       /**
       * Find by id.
       *
       * @param id the id
       *
       * @return the t
       */
       public abstract T findById(final ID id);
      
       /**
       * Gets the id.
       *
       * @param row the row
       *
       * @return the id
       */
       @SuppressWarnings("unchecked")
       public ID getId(final T row) {
       ID id = (ID) row.getId();
      
       return id;
       }
      
       /**
       * Wrap.
       *
       * @param context the context
       * @param visitor the visitor
       * @param range the range
       * @param argument the argument
       * @param list the list
       *
       * @throws IOException Signals that an I/O exception has occurred.
       */
       public void wrap(final FacesContext context, final DataVisitor visitor,
       final Range range, final Object argument, final List<T> list)
       throws IOException {
       wrappedKeys = new ArrayList<ID>();
       wrappedData = new HashMap<ID, T>();
      
       for (final T row : list) {
       ID id = getId(row);
       wrappedKeys.add(id);
       wrappedData.put(id, row);
       visitor.process(context, id, argument);
       }
       }
      
       /**
       * Checks for by id.
       *
       * @param id the id
       *
       * @return true, if successful
       */
       public boolean hasById(final ID id) {
       for (final T row : listRow) {
       ID rowId = getId(row);
      
       if (rowId.equals(id)) {
       return true;
       }
       }
      
       return false;
       }
      
       /**
       * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
       */
       @Override
       public void walk(final FacesContext context, final DataVisitor visitor,
       final Range range, final Object argument) throws IOException {
       int firstRow = ((SequenceRange) range).getFirstRow();
       int maxResults = ((SequenceRange) range).getRows();
       wrap(context, visitor, range, argument, loadList(firstRow, maxResults));
       }
      
       /*
       * This method normally called by Visitor before request Data Row.
       */
       /**
       * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
       */
       @Override
       @SuppressWarnings("unchecked")
       public void setRowKey(final Object key) {
       this.currentId = (ID) key;
       }
      
       /**
       * @see javax.faces.model.DataModel#getRowCount()
       */
       @Override
       public int getRowCount() {
       return this.getCount().intValue();
       }
      
       /**
       * @see javax.faces.model.DataModel#isRowAvailable()
       */
       @Override
       public boolean isRowAvailable() {
       if (currentId == null) {
       return false;
       } else {
       return hasById(currentId);
       }
       }
      
       /**
       * @see javax.faces.model.DataModel#getRowData()
       */
       @Override
       public Object getRowData() {
       if (currentId == null) {
       return null;
       } else {
       T ret = wrappedData.get(currentId);
      
       if (ret == null) {
       ret = this.findById(currentId);
       wrappedData.put(currentId, ret);
      
       return ret;
       } else {
       return ret;
       }
       }
       }
      
       // Unused rudiment from old JSF staff.
       /**
       * @see javax.faces.model.DataModel#getRowIndex()
       */
       @Override
       public int getRowIndex() {
       return 0;
       }
      
       /**
       * @see javax.faces.model.DataModel#setRowIndex(int)
       */
       @Override
       public void setRowIndex(final int rowIndex) {
       }
      
       /**
       * @see javax.faces.model.DataModel#getWrappedData()
       */
       @Override
       public Object getWrappedData() {
       return this;
       }
      
       /**
       * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
       */
       @Override
       public void setWrappedData(final Object data) {
       throw new UnsupportedOperationException();
       }
      
       /**
       * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
       */
       @Override
       public Object getRowKey() {
       return currentId;
       }
      
       /**
       * Adds the error message.
       *
       * @param summary the summary
       * @param detail the detail
       */
       protected void addErrorMessage(String summary, String detail) {
       FacesMessage errorMessage = new FacesMessage();
       errorMessage.setSummary(summary);
       errorMessage.setDetail(detail);
       errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
       FacesContext.getCurrentInstance().addMessage(null, errorMessage);
       }
      
       /**
       * Adds the info message.
       *
       * @param summary the summary
       * @param detail the detail
       */
       protected void addInfoMessage(String summary, String detail) {
       FacesMessage infoMessage = new FacesMessage();
       infoMessage.setSummary(summary);
       infoMessage.setDetail(detail);
       infoMessage.setSeverity(FacesMessage.SEVERITY_INFO);
       FacesContext.getCurrentInstance().addMessage(null, infoMessage);
       }
      }
      


      A dataModel who extends from this one, is used to display a dataTable. The pagination works fine, but the columns with a sortBy property gives me this exception:

      When using a dataModel to display a list in a dataTable, and implementing rich's orderBy tag in each column, I got this error after clicking in a column :
      
      
      23:30:58,330 ERROR [STDERR] Aug 13, 2008 11:30:58 PM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/app/index.xhtml]
      javax.faces.FacesException: javax.ejb.EJBTransactionRolledbackException: Negative (-1) parameter passed in to setMaxResults
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:675)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:541)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:613)
      Caused by: javax.ejb.EJBTransactionRolledbackException: Negative (-1) parameter passed in to setMaxResults
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy138.obtenerPorEstadoUnidad(Unknown Source)
       at ec.gov.seguridadciudadana.dts.servicio.impl.TramiteServicioImpl.obtenerPorEstadoUnidad(TramiteServicioImpl.java:143)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb
      23:30:58,331 ERROR [STDERR] 3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy214.obtenerPorEstadoUnidad(Unknown Source)
       at ec.gov.seguridadciudadana.dts.datamodel.TramiteDataModel.getList(TramiteDataModel.java:81)
       at ec.gov.seguridadciudadana.dts.datamodel.GenericDataModel.loadList(GenericDataModel.java:101)
       at ec.gov.seguridadciudadana.dts.datamodel.GenericDataModel.walk(GenericDataModel.java:179)
       at org.richfaces.model.ModifiableModel.prepareCollection(ModifiableModel.java:142)
       at org.richfaces.model.ModifiableModel.walk(ModifiableModel.java:111)
       at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1127)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:106)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:91)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractRowsRenderer.java:138)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:125)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
       at org.ajax4jsf.component.UIAjaxRegion.encodeAjax(UIAjaxRegion.java:267)
       at org.ajax4jsf.component.AjaxViewRoot$4.invokeContextCallback(AjaxViewRoot.java:485)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:672)
       ... 47 more
      Caused by: java.lang.IllegalArgumentException: Negative (-1) parameter passed in to setMaxResults
       at org.hibernate.ejb.QueryImpl.setMaxResults(QueryImpl.java:106)
       at ec.gov.seguridadciudadana.dts.dao.impl.TramiteDaoImpl.obtenerPorEstadoUnidad(TramiteDaoImpl.java:70)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
       ... 125 more
      23:30:58,332 WARN [lifecycle] executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@276dca) threw exception
      javax.faces.FacesException: javax.ejb.EJBTransactionRolledbackException: Negative (-1) parameter passed in to setMaxResults
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:675)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:541)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:613)
      Caused by: javax.ejb.EJBTransactionRolledbackException: Negative (-1) parameter passed in to setMaxResults
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy138.obtenerPorEstadoUnidad(Unknown Source)
       at ec.gov.seguridadciudadana.dts.servicio.impl.TramiteServicioImpl.obtenerPorEstadoUnidad(TramiteServicioImpl.java:143)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy214.obtenerPorEstadoUnidad(Unknown Source)
       at ec.gov.seguridadciudadana.dts.datamodel.TramiteDataModel.getList(TramiteDataModel.java:81)
       at ec.gov.seguridadciudadana.dts.datamodel.GenericDataModel.loadList(GenericDataModel.java:101)
       at ec.gov.seguridadciudadana.dts.datamodel.GenericDataModel.walk(GenericDataModel.java:179)
       at org.richfaces.model.ModifiableModel.prepareCollection(ModifiableModel.java:142)
       at org.richfaces.model.ModifiableModel.walk(ModifiableModel.java:111)
       at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1127)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:106)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:91)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractRowsRenderer.java:138)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:125)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
       at org.ajax4jsf.component.UIAjaxRegion.encodeAjax(UIAjaxRegion.java:267)
       at org.ajax4jsf.component.AjaxViewRoot$4.invokeContextCallback(AjaxViewRoot.java:485)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:672)
       ... 47 more
      Caused by: java.lang.IllegalArgumentException: Negative (-1) parameter passed in to setMaxResults
       at org.hibernate.ejb.QueryImpl.setMaxResults(QueryImpl.java:106)
       at ec.gov.seguridadciudadana.dts.dao.impl.TramiteDaoImpl.obtenerPorEstadoUnidad(TramiteDaoImpl.java:70)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
       ... 125 more
      23:30:58,335 ERROR [BaseXMLFilter] Exception in the filter chain
      javax.servlet.ServletException: Negative (-1) parameter passed in to setMaxResults
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:613)
      Caused by: javax.ejb.EJBTransactionRolledbackException: Negative (-1) parameter passed in to setMaxResults
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy138.obtenerPorEstadoUnidad(Unknown Source)
       at ec.gov.seguridadciudadana.dts.servicio.impl.TramiteServicioImpl.obtenerPorEstadoUnidad(TramiteServicioImpl.java:143)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy214.obtenerPorEstadoUnidad(Unknown Source)
       at ec.gov.seguridadciudadana.dts.datamodel.TramiteDataModel.getList(TramiteDataModel.java:81)
       at ec.gov.seguridadciudadana.dts.datamodel.GenericDataModel.loadList(GenericDataModel.java:101)
       at ec.gov.seguridadciudadana.dts.datamodel.GenericDataModel.walk(GenericDataModel.java:179)
       at org.richfaces.model.ModifiableModel.prepareCollection(ModifiableModel.java:142)
       at org.richfaces.model.ModifiableModel.walk(ModifiableModel.java:111)
       at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1127)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:106)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:91)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractRowsRenderer.java:138)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:125)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
       at org.ajax4jsf.component.UIAjaxRegion.encodeAjax(UIAjaxRegion.java:267)
       at org.ajax4jsf.component.AjaxViewRoot$4.invokeContextCallback(AjaxViewRoot.java:485)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:672)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:541)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       ... 25 more
      Caused by: java.lang.IllegalArgumentException: Negative (-1) parameter passed in to setMaxResults
       at org.hibernate.ejb.QueryImpl.setMaxResults(QueryImpl.java:106)
       at ec.gov.seguridadciudadana.dts.dao.impl.TramiteDaoImpl.obtenerPorEstadoUnidad(TramiteDaoImpl.java:70)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
       ... 125 more
      23:30:58,338 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      java.lang.IllegalArgumentException: Negative (-1) parameter passed in to setMaxResults
       at org.hibernate.ejb.QueryImpl.setMaxResults(QueryImpl.java:106)
       at ec.gov.seguridadciudadana.dts.dao.impl.TramiteDaoImpl.obtenerPorEstadoUnidad(TramiteDaoImpl.java:70)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy138.obtenerPorEstadoUnidad(Unknown Source)
       at ec.gov.seguridadciudadana.dts.servicio.impl.TramiteServicioImpl.obtenerPorEstadoUnidad(TramiteServicioImpl.java:143)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy214.obtenerPorEstadoUnidad(Unknown Source)
       at ec.gov.seguridadciudadana.dts.datamodel.TramiteDataModel.getList(TramiteDataModel.java:81)
       at ec.gov.seguridadciudadana.dts.datamodel.GenericDataModel.loadList(GenericDataModel.java:101)
       at ec.gov.seguridadciudadana.dts.datamodel.GenericDataModel.walk(GenericDataModel.java:179)
       at org.richfaces.model.ModifiableModel.prepareCollection(ModifiableModel.java:142)
       at org.richfaces.model.ModifiableModel.walk(ModifiableModel.java:111)
       at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1127)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:106)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:91)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractRowsRenderer.java:138)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:125)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
       at org.ajax4jsf.component.UIAjaxRegion.encodeAjax(UIAjaxRegion.java:267)
       at org.ajax4jsf.component.AjaxViewRoot$4.invokeContextCallback(AjaxViewRoot.java:485)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:672)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:541)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:613)
      
      


      Any suggestions about this ??

      thanks a lot

        • 1. Re: Problem with order using DataModel
          Wagner Da Silva Newbie

           

          When using a dataModel to display a list in a dataTable, and implementing rich's orderBy tag in each
          column, I got this error after clicking in a column :

          javax.faces.FacesException: javax.ejb.EJBTransactionRolledbackException: Negative (-1) parameter pas
          sed in to setMaxResults


          I can also reproduce the same issue when trying to use the ExtendedDataModel together with the rich:dataTable component. As soon as I enable the sorting feature like this:

          <rich:column sortBy="#{account.name}">


          And then I click on the column to sort it, somehow the walk method gets called many times, but one of those calls will have a maxResults with -1.

          public void walk(final FacesContext context, final DataVisitor visitor,
           final Range range, final Object argument) throws IOException {
           int firstRow = ((SequenceRange) range).getFirstRow();
           int maxResults = ((SequenceRange) range).getRows(); -> this will became -1 when trying to sort.
          


          Now I wonder, have anyone being able to use sorting while using ExtendedDataModel and rich:dataTable???

          • 2. Re: Problem with order using DataModel
            Andre Eugenio Newbie

            To order and filter you need to implement org.richfaces.model.Modifiable

            • 3. Re: Problem with order using DataModel
              bobo Liu Newbie

               

              "andre.eugenio" wrote:
              To order and filter you need to implement org.richfaces.model.Modifiable


              thanks, this help me! I read many post, but can not find the solution.
              but how do you implement the modify method. I done it like this, but I think it is not reasonale.

              @Override
               public void modify(List<FilterField> filterList, List<SortField2> sorterList) {
              
               if (sorterList.size() > 0) {
               SortField2 s = sorterList.get(0);
              
               String exp = s.getExpression().getExpressionString();
               String column = exp.substring(exp.indexOf('{') + 1, exp.lastIndexOf('}'));
               if (s.getOrdering().equals(Ordering.ASCENDING)) {
               column += " asc";
               } else if (s.getOrdering().equals(Ordering.DESCENDING)) {
               column += " desc";
               }
               entityQuery.setOrder(column);
               }
              
               }


              • 4. Re: Problem with order using DataModel
                Andre Eugenio Newbie

                Sorry the long delay, hope the following code help you.

                This is my BaseExtendedDataModel (based on code from other post modified to use hibernate and seam)

                public abstract class BaseExtendedDataModel<T,ID extends Serializable>
                 extends ExtendedDataModel
                 implements BaseExtendedDataModelDAO<T, ID>, Modifiable
                 {
                
                 private @Logger Log log;
                
                 int rowNum=-1;
                
                 public int getRowNum()
                 {
                 return ++rowNum;
                 }
                
                 public List<T> listRow;
                
                 private ID currentId;
                 private Map<ID, T> wrappedData = new HashMap<ID, T>();
                 private List<ID> wrappedKeys;
                 private Long rowCount; // better to buffer row count locally
                
                // public abstract Long getCount();
                // public abstract List<T> getList(Integer firstRow, Integer maxResults);
                 public abstract T findById(ID id);
                
                 @SuppressWarnings("unchecked")
                 public ID getId(T row)
                 {
                 ID id = (ID) ((com.sssi.entity.EntityId)row).getDefaultId();
                 return id;
                 }
                
                 public void wrap(FacesContext context, DataVisitor visitor, Range range, Object argument, List<T> list) throws IOException
                 {
                 wrappedKeys = new ArrayList<ID>();
                 wrappedData = new HashMap<ID, T>();
                 for (T row : list)
                 {
                 ID id = getId(row);
                 wrappedKeys.add(id);
                 wrappedData.put(id, row);
                 visitor.process(context, id, argument);
                 }
                 }
                
                 public boolean hasById(ID id)
                 {
                 for (T row : listRow)
                 {
                 ID rowId = getId(row);
                 if (rowId.equals(id))
                 return true;
                 }
                 return false;
                 }
                
                 @Override
                 public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException
                 {
                 int firstRow = ((SequenceRange) range).getFirstRow();
                 int maxResults = ((SequenceRange) range).getRows();
                 log.info("("+firstRow +", "+ maxResults+")");
                 wrap(context, visitor, range, argument, getList(firstRow, maxResults));
                 }
                
                 /*
                 * This method normally called by Visitor before request Data Row.
                 */
                 @SuppressWarnings("unchecked")
                 @Override
                 public void setRowKey(Object key)
                 {
                 this.currentId = (ID) key;
                 }
                
                // @Override
                // public int getRowCount()
                // {
                // if(rowCount == null)
                // return (rowCount = this.getCount()).intValue();
                // else
                // return rowCount.intValue();
                // }
                
                 @Override
                 public boolean isRowAvailable()
                 {
                 if (currentId == null)
                 return false;
                 else
                 return hasById(currentId);
                 }
                
                 /**
                 * This is main way to obtain data row. It is intensively used by framework.
                 * We strongly recommend use of local cache in that method.
                 */
                 @Override
                 public Object getRowData() {
                 if (currentId == null)
                 return null;
                 else {
                 T ret = wrappedData.get(currentId);
                 if (ret == null) {
                 ret = this.findById(currentId);
                 wrappedData.put(currentId, ret);
                 return ret;
                 }
                 else
                 return ret;
                 }
                 }
                
                
                 // Unused rudiment from old JSF staff.
                 @Override public int getRowIndex() { throw new UnsupportedOperationException(); }
                 @Override public void setRowIndex(int rowIndex) { throw new UnsupportedOperationException(); }
                 @Override public Object getWrappedData() { throw new UnsupportedOperationException(); }
                 @Override public void setWrappedData(Object data) { throw new UnsupportedOperationException(); }
                
                 // TODO if this is never called by the framework why is it necessary.
                 @Override public Object getRowKey() { throw new UnsupportedOperationException(); }
                
                
                 /*
                 * (non-Javadoc)
                 * @see org.richfaces.model.Modifiable#modify(java.util.List, java.util.List)
                 */
                
                
                 public String orderField;
                 public Ordering orderType;
                 public List<String> filterParmSql;
                 public List<String> filterValueSql;
                 public abstract Criteria createQuery();
                
                 @Override
                 public void modify(List<FilterField> filterBy, List<SortField2> sortBy) {
                 filterParmSql = new ArrayList<String>();
                 filterValueSql = new ArrayList<String>();
                 for(FilterField field : filterBy)
                 if(((ExtendedFilterField)field).getFilterValue() != null && ((ExtendedFilterField)field).getFilterValue().length() > 0) {
                 filterParmSql.add(removeElTrailling(field.getExpression().getExpressionString()));
                 filterValueSql.add(((ExtendedFilterField)field).getFilterValue());
                 }
                 if(sortBy.size() > 0 && sortBy.get(0).getOrdering() != Ordering.UNSORTED) {
                 orderField = removeElTrailling(sortBy.get(0).getExpression().getExpressionString());
                 orderType = sortBy.get(0).getOrdering();
                 }
                 }
                
                 @Override
                 public int getRowCount()
                 {
                 if(rowCount == null) {
                 Criteria sql = createQuery();
                 sql.setProjection(Projections.rowCount());
                 rowCount = Long.parseLong(sql.list().get(0).toString());
                 }
                 return rowCount.intValue();
                 }
                
                 // TODO find something more smarter
                 private String removeElTrailling(String elString) {
                 elString = elString.replace("{", "").replace("}", "");
                 return elString.substring(elString.indexOf(".")+1);
                 }
                
                 @SuppressWarnings("unchecked")
                 private List<T> getList(Integer firstRow, Integer maxResults)
                 {
                 Criteria sql = createQuery();
                 sql.setFirstResult(firstRow);
                 sql.setMaxResults(maxResults);
                 listRow = sql.list();
                 return listRow;
                 }
                
                
                }
                


                This is a seam component that uses the classe above
                @Name("categoryExtendedDataModel")
                public class CategoryExtendedDataModel extends BaseExtendedDataModel<Object, Long> {
                
                 @In
                 private Session hibernateSession;
                
                 @Override
                 public Object findById(Long id)
                 {
                 Object object = hibernateSession.get(TbCategory.class, id);
                 return object;
                 }
                
                 public Criteria createQuery() {
                 Criteria sql = hibernateSession.createCriteria(TbCategory.class);
                 for(int i=0;i<filterParmSql.size();i++)
                 sql.add(Restrictions.ilike(filterParmSql.get(i), "%"+filterValueSql.get(i)+"%"));
                 if(orderField != null && orderField.length()>0)
                 sql.addOrder(orderType == Ordering.ASCENDING ? Order.asc(orderField) : Order.desc(orderField));
                 return sql;
                 }
                
                 @SuppressWarnings("unchecked")
                 public List<Object> getList(Integer firstRow, Integer maxResults)
                 {
                 Criteria sql = createQuery();
                 sql.setFirstResult(firstRow);
                 sql.setMaxResults(maxResults);
                 listRow = sql.list();
                 return listRow;
                 }
                
                }
                



                • 5. Re: Problem with order using DataModel
                  Andre Eugenio Newbie

                  The getList method from CategoryExtendedDataModel class is redundant, and as you can see on the code above I just use the Criteria from hibernate to do the filter and sort in database.