1 Reply Latest reply on Mar 31, 2008 12:38 PM by pmuir

    Issue with EntityQuery.getResultList()

    chamzhang

      Dear All:


      i got a issue when i am using EntityQuery.getResultList(); since EntityQuery.getResultList() might result some list under proxy of javassist; when i am trying to cast it i got such a exception


      javax.faces.FacesException: #{productAction.findProdCat}: java.lang.ClassCastException: com.risi.ttps.dao.ProdCatList_$$_javassist_3 cannot be cast to javax.faces.model.DataModel



      following is my code:


      @Name("prodCatList")
      
      public class ProdCatList extends EntityQuery<ProdCat> {
      
      ...
      
      }



      @Name("productService")
      
      public class ProductService implements Serializable {
      
      
              @In(create = true)
      
              private ProdCatList prodCatList;
      
      
      
              public List<ProdCat> findProdCat(ProdCat cat) {
      
                      prodCatList.setProdCat(cat);
      
                      
      
                      List<ProdCat> res = prodCatList.getResultList();
      
                      
      
                      return res;
      
              }
      
      
      }



      btw: if i could set the search critrition via this way:


      prodCatList.setProdCat(cat);

        • 1. Re: Issue with EntityQuery.getResultList()
          pmuir

          List doesn't extend DataModel!


          Try


          @Name("productService")
          public class ProductService implements Serializable {
          
             @In(create = true)
             private ProdCatList prodCatList;
          
          
             public DataModel findProdCat(ProdCat cat) {
                prodCatList.setProdCat(cat);
                return prodCatList.getDataModel();
             }
          
          }



          Btw. please use back ticks to surround code blocks (I fixed up your post for you...)