6 Replies Latest reply on Oct 25, 2010 11:10 AM by Tom Esposito

    s:convertEntity when  a failed transaction

    Alex Sun Newbie

      In a long running conversation:


      i have a query form:


      <s:decorate id="ndDecoration" template="/layout/display.xhtml">
                     <ui:define name="label">nd:</ui:define>
                     <h:selectOneMenu id="exampleNd" value="#{zszyQuery.exampleEntity.nd}" >
                               <s:selectItems value="#{globalService.yearSelectItems()}" var="year" label="#{year}" noSelectionLabel="--please select--" />
                               <a:support event="onchange" actionListener="#{zszyQuery.refreshQuery}" reRender="queryForm,searchResults">
                                    <f:param name="firstResult" value="0"/>
                               </a:support>
                          </h:selectOneMenu>
                 </s:decorate>
                 <s:decorate id="yxDecoration" template="/layout/display.xhtml">
                     <ui:define name="label">yx:</ui:define>
                     <h:selectOneMenu value="#{zszyQuery.exampleEntity.yx}" >
                               <s:selectItems value="#{zszyYxQuery.resultList}" var="yx" label="[#{yx.dm}]#{yx.name}" noSelectionLabel="--please select--" />
                               <s:convertEntity />
                               <a:support event="onchange" actionListener="#{zszyQuery.refreshQuery}" action="#{zszyZyQuery.refreshQuery}" reRender="globalMessages,queryForm,searchResults">
                                    <f:param name="firstResult" value="0"/>
                               </a:support>
                          </h:selectOneMenu>
                 </s:decorate>



      when i change the second selectOneMenu's value, zszyQuery.refreshQuery() happens an exception:



      INFO: select count ejbql:SELECT COUNT( zszy ) FROM app.zsml.model.entity.ZS_ZY zszy WHERE ( ( 1=1) ) AND ( ( ( ( ( zszy.nd = #{zszyQuery.exampleEntity.nd}) AND ( ( zszy.yx = #{zszyQuery.exampleEntity.yx}) AND ( ( ( ( ( zszy.zy = #{zszyQuery.exampleEntity.zy}) ) ) ) ) ) ) ) ) ) 
      Hibernate: select count(zs_zy0_.id) as col_0_0_ from T_ZSML_ZSZY zs_zy0_ where 1=1 and zs_zy0_.nd=? and zs_zy0_.YX_ID=? and zs_zy0_.ZY_ID=?
      Hibernate: select * from ( select zs_zy0_.id as id6_, zs_zy0_.bz as bz6_, zs_zy0_.nd as nd6_, zs_zy0_.YX_ID as YX6_6_, zs_zy0_.zsrs as zsrs6_, zs_zy0_.ZY_ID as ZY5_6_ from T_ZSML_ZSZY zs_zy0_ where 1=1 and zs_zy0_.nd=? and zs_zy0_.YX_ID=? and zs_zy0_.ZY_ID=? ) where rownum <= ?
      2008-4-3 9:16:58 epstar.framework.RestrictedEntityQuery getCountEjbql
      INFO: select count ejbql:SELECT COUNT( zszy ) FROM app.zsml.model.entity.ZS_ZY zszy WHERE ( ( 1=1) ) AND ( ( ( ( ( zszy.nd = #{zszyQuery.exampleEntity.nd}) AND ( ( ( ( ( ( zszy.zy = #{zszyQuery.exampleEntity.zy}) ) ) ) ) ) ) ) ) ) 
      2008-4-3 9:16:58 com.sun.faces.lifecycle.UpdateModelValuesPhase execute
      WARN: javax.el.ELException: /file:/E:/Project/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/app-facelet/WEB-INF/lib/module-zsml.jar!/zsml.xhtml @140,101 rendered="#{zszyQuery != null and zszyQuery.resultCount==0}": java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [el3]
      2008-4-3 9:16:58 epstar.framework.RestrictedEntityQuery getEjbql
      INFO: select ejbql:SELECT DISTINCT zy FROM app.zsml.model.entity.ZS_ZY zszy  JOIN  zszy.zy zy WHERE ( ( 1=1) ) AND ( ( ( ( ( zszy.nd = #{zszyZyQuery.exampleEntity.nd}) AND ( ( ( ( ( ( ( zy is not null) ) ) ) ) ) ) ) ) ) ) 
      
      .............................
      
      2008-4-3 9:16:59 com.sun.faces.lifecycle.RenderResponsePhase execute
      INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=null[severity=(WARN 1), summary=(Transaction failed), detail=(Transaction failed)]



      my question is not about this exception,here is my question:
      when i continue changing the selectOneMenu's value, a Validation Error occurs:



      2008-4-3 9:19:36 com.sun.faces.lifecycle.RenderResponsePhase execute
      INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=tZsmlZszySearch:yxDecoration:j_id25[severity=(ERROR 2), summary=(tZsmlZszySearch:yxDecoration:j_id25: Validation Error: Value is not valid), detail=(tZsmlZszySearch:yxDecoration:j_id25: Validation Error: Value is not valid)]



      by debugging the source code, i found:


      javax.faces.component.UISelectOne.validateValue(FacesContext, Object):
       // Ensure that the value matches one of the available options
              boolean found = matchValue(value, new SelectItemsIterator(this));



      the matchValue method returns false, the value's entity instance dose not equals the new submitted value's entity instance, there are two instance of the same entity.


      is there a problem with s:convertEntity in a long running conversation when a failed transaction ?


      anyone help me?


      Thanks.

        • 2. Re: s:convertEntity when  a failed transaction
          Pete Muir Master

          Alex Sun wrote on Apr 03, 2008 05:43 AM:


          is there a problem with s:convertEntity in a long running conversation when a failed transaction ?

          Thanks.



          A failed transaction is a serious error. The conversation itself is OK, but you will need to start a new request.

          • 3. Re: s:convertEntity when  a failed transaction
            Alex Sun Newbie

            Pete Muir wrote on Apr 06, 2008 11:47 AM:


            A failed transaction is a serious error. The conversation itself is OK, but you will need to start a new request.


            you mean starting a new request by clearing the conversationId request param? That will begin a new conversation and the data in the old conversation's state will be lost.


            any ideas?


            Thanks.

            • 4. Re: s:convertEntity when  a failed transaction
              Alex Sun Newbie

              For more detailed information:


              I have a entity query which overrides the getEjbql method:


              @Override
                   public String getEjbql() {
                        EntityRestriction restriction = buildRestriction();
              
                        StringBuffer qlBuilder = new StringBuffer();
                        if (isQueryProperty()) {
                             qlBuilder.append(restriction.renderSelectClause(
                                       EntityFilterType.QUERY, false,
                                       getQueryPropertyEntityAlias()));
                        } else {
                             qlBuilder.append(restriction.renderSelectClause(
                                       EntityFilterType.QUERY, false, null));
                        }
              
                        qlBuilder.append(restriction.renderFromClause());
                        qlBuilder.append(restriction.renderJoinWhereClause(
                                  EntityFilterType.QUERY, true));
                        String result = qlBuilder.toString();
                        log.info("select ejbql:" + result);
                        return result;
                   }



              This method returns dynamic ejbql accroding to the query form's submitted values, the problem i mentioned is occured when i set back the selectOneMenu's value to '--please select--', this trigger the ajax request, and on JSF's UpdateModelValuesPhase, it throws a warn message:'java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter (el3)', because one of the ejbql's parameters has bean null, and after this warn message, seam throws a 'Transaction failed' exception.


              After these all steps, no matter what i change the selectOneMenu's value, JSF gives me a 'Validation Error' message in the log.

              • 5. Re: s:convertEntity when  a failed transaction
                Alex Sun Newbie

                BTW, my entity query is in a conversation scope.

                • 6. Re: s:convertEntity when  a failed transaction
                  Tom Esposito Newbie

                  Any luck finding an answer to this?  I have the same problem.  Once I get the  Transaction failed message within a long running conversation, the user cannot submit the page without getting the value is not valid message.  I'd like to think that my application will never have errors, but I'd like to code around these issues if possible.


                  Any advice would be welcomed.