0 Replies Latest reply on Oct 5, 2009 8:13 PM by Val Sw

    Which is better for performance in Seam

    Val Sw Expert
      Hi,

      What will be the best practice with-in seam framework.

      Scenario :
      We are sending Ajax request (using suggestionBox) to fetch itemNames when user enters text.
      We have list of approximately 5000 item names, corresponding entity is Item.

      What will be the best practice option to get list of itemNames on the basis of text entered in suggestion box by user (we want to query result only for the text entered)

      a) Define framework:entity-query in components.xml, call this to fetch itemNames when user enters text.

      b) Use built-in ejbql in corresponding itemList.java (default generated by seam)
      @Override
      public String getEjbql() {
        return "select item from Item item";
      }

      c) Create separate query using enityManager in some bean class, add where clause passing the text entered by user.
      public List<Item> getItemsList(String itemName) {          
        List<Item> itemLst = entityManager.createQuery("select item from Item item.... where  
            item.itemName=<itemName>").getResultList();
        return itemLst;
      }