s:convertEntity when a failed transaction
zjsun Apr 3, 2008 5:43 AMIn 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.