Warning and Transaction Failed on EntityQuery
sandman202 Aug 17, 2008 5:20 AMI have a class called CodeList.java that I use to retrieve a listing when I perform a search. On my search CodeList.xhtml when I select both type and active, I receive on the top of the screen is Transaction failed
. However, if I select only one of these options, it works just fine. In the log file I also see the following:
21:58:02,415 WARN  [lifecycle] javax.el.ELException: /CodeList.xhtml @63,65 rendered="#{empty codeList.resultList}": Error reading 'resultList' on type com.ds.artwork.CodeList_$$_javassist_10
CodeList.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a="http://richfaces.org/a4j"                
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message"/>
    
    <h:form id="cityStateZipSearch" styleClass="edit">
    
        <rich:simpleTogglePanel label="Code Search Parameters" switchType="ajax">
                                
                <s:decorate id="typeDecoration" template="layout/display.xhtml">
                <ui:define name="label">Type</ui:define>               
                        <h:selectOneMenu value="#{codeList.code.type}" id="codeType" >
                                <s:selectItems value="#{codeList.codeTypes}" var="_codeType" label="#{_codeType.value}" 
                                                           noSelectionLabel="Please Select Type... "/>
                                <s:convertEnum />
                        </h:selectOneMenu>
                </s:decorate>
                        
            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Code</ui:define>
                <h:inputText id="code" value="#{codeList.code.code}"/>
            </s:decorate>
                    
            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Description</ui:define>
                <h:inputText id="description" value="#{codeList.code.description}"/>
            </s:decorate>
                    
            <s:decorate id="activeDecoration" template="layout/display.xhtml">
                <ui:define name="label">Active</ui:define>               
                        <h:selectOneMenu id="active" 
                                      value="#{codeList.code.strActive}">                               
                             <f:selectItems value="#{codeList.booleanCodes}" />                                   
                        </h:selectOneMenu>
                </s:decorate>              
        
        </rich:simpleTogglePanel>
        
        <div class="actionButtons">
            <h:commandButton id="search" value="Search" action="/CodeList.xhtml"/>
        </div>
        
    </h:form>  
    
        
    
    <rich:panel>
        <f:facet name="header">Code Search Results</f:facet>
        
        <div class="results" id="codeList">
        
            <h:outputText value="No code exists" 
                       rendered="#{empty codeList.resultList}"/>
                   
            <rich:dataTable id="codeList" 
                                   var="_code"
                         value="#{codeList.resultList}" 
                      rendered="#{not empty codeList.resultList}">
                   
                        <h:column>
                            <f:facet name="header">
                                <s:link styleClass="columnHeader"
                                             value="Type #{codeList.order=='type.value asc' ? messages.down : ( codeList.order=='type.value desc' ? messages.up : '' )}">
                                    <f:param name="order" value="#{codeList.order=='type.value asc' ? 'type.value desc' : 'type.value asc'}"/>
                                </s:link>
                            </f:facet>
                            #{_code.type}
                        </h:column>
                           
                        <h:column>
                            <f:facet name="header">
                                <s:link styleClass="columnHeader"
                                             value="Code #{codeList.order=='code asc' ? messages.down : ( codeList.order=='code desc' ? messages.up : '' )}">
                                    <f:param name="order" value="#{codeList.order=='code asc' ? 'code desc' : 'code asc'}"/>
                                </s:link>
                            </f:facet>
                            #{_code.code}
                        </h:column>  
                        
                        <h:column>
                            <f:facet name="header">
                                <s:link styleClass="columnHeader"
                                             value="Description #{codeList.order=='description asc' ? messages.down : ( codeList.order=='description desc' ? messages.up : '' )}">
                                    <f:param name="order" value="#{codeList.order=='description asc' ? 'description desc' : 'description asc'}"/>
                                </s:link>
                            </f:facet>
                            #{_code.description}
                        </h:column>               
                        
                        <h:column>
                            <f:facet name="header">
                                <s:link styleClass="columnHeader"
                                             value="Available #{codeList.order=='active asc' ? messages.down : ( codeList.order=='active desc' ? messages.up : '' )}">
                                    <f:param name="order" value="#{codeList.order=='active asc' ? 'active desc' : 'active asc'}"/>
                                </s:link>
                            </f:facet>
                            #{_code.active}
                        </h:column> 
                        
                
                                    
                        <h:column>
                            <f:facet name="header">Action</f:facet>
                            <s:link view="/#{empty from ? 'Code' : from}.xhtml" 
                                   value="Select" 
                                      id="code">
                                <f:param name="codeId" 
                                        value="#{_code.id}"/>
                            </s:link>
                        </h:column>
                        
            </rich:dataTable>
        
        </div>
        
    </rich:panel>
    
    <s:div styleClass="actionButtons" rendered="#{empty from}">
        <s:button view="/CodeEdit.xhtml"
                    id="create" 
                 value="Create Code">
            <f:param name="codeId"/>
        </s:button>                         
    </s:div>
    
</ui:define>
</ui:composition>
CodeList.java
package com.ds.artwork;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.faces.model.SelectItem;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import com.ds.artwork.entity.Code;
import com.ds.artwork.entity.Item;
import com.ds.artwork.utils.CodeType;
@Name("codeList")
public class CodeList extends EntityQuery<Item> {
        private static final long serialVersionUID = 1008397397027179231L;
        // @In(required=false) @Out(required=false)
        // private String active = "";
        private static final String[] RESTRICTIONS = {
                        "code.type = #{codeList.code.type}",
                        "lower(code.code) like concat(lower(#{codeList.code.code}),'%')",
                        "lower(code.description) like concat(lower(#{codeList.code.description}),'%')", 
                        };
        private Code code = new Code();
        @Override
        public String getEjbql() {
                return "select code from Code code";
        }
        @Override
        public Integer getMaxResults() {
                return 25;
        }
        public Code getCode() {
                return code;
        }
        @Override
        public List<String> getRestrictions() {
                // return Arrays.asList(RESTRICTIONS);
                //List<String> restrictions = Arrays.asList(RESTRICTIONS);
        
                ArrayList<String> restrictions = new ArrayList<String>(0);
                restrictions.addAll(Arrays.asList(RESTRICTIONS));
                if (code.getStrActive() != null) {
                        restrictions.add("code.active = #{" + Boolean.valueOf(code.getStrActive()) + "}");
                }
                return restrictions;
        }
        
        @Override
        public String getOrder() {
                if (super.getOrder() == null) {
                        setOrder("type asc");
                }
                return super.getOrder();
        }
        public CodeType[] getCodeTypes() {
                return CodeType.values();
        }
        @SuppressWarnings("unchecked")
        public List<Code> getBooleanCodes() {
                // return
                // this.getEntityManager().createNamedQuery("code.findCodesByType").setParameter("type",
                // CodeType.BOOLEAN).getResultList();
                List choices = new ArrayList();
                choices.add(new SelectItem("", " "));
                choices.add(new SelectItem("true", "True"));
                choices.add(new SelectItem("false", "False"));
                return choices;
        }
        @SuppressWarnings("unchecked")
        public List<Code> getEditionCodes() {
                return this.getEntityManager().createNamedQuery("code.findCodesByType")
                                .setParameter("type", CodeType.EDITION).getResultList();
        }
        @SuppressWarnings("unchecked")
        public List<Code> getMediumCodes() {
                return this.getEntityManager().createNamedQuery("code.findCodesByType")
                                .setParameter("type", CodeType.MEDIUM).getResultList();
        }
}
Does anyone know what the problem is?
 
    