2 Replies Latest reply on Jan 24, 2007 5:11 AM by paradigmza

    Using EntityQuery Restrictions in Code

    paradigmza

      Hi,

      I would like to know the proper way to use seam restriction in the code.

      I used to have a way that worked in Seam 1.1.0 but it stopped working in 1.1.1 (hence must be the incorrect way to use them)

      List<String> restrictions = new ArrayList<String>();
      restrictions.add("username like #{'" + value + "%'}");
      EntityQuery nameList = new MyUserList();
      nameList.setRestrictions(restrictions);
      Long i = nameList.getResultCount();
      log.info("search.searchUserNames() called with count: #0", i);
      

      and
      List<String> restrictions = new ArrayList<String>();
      restrictions.add("name like #{'" + value + "%'}");
      EntityQuery clientList = new MyClientList();
      clientList.setRestrictions(restrictions);
      Long i = clientList.getResultCount();
      log.info("search.searchClients() called with count: #0", i);
      


      With the upgrade to Seam 1.1.1 the resultCount is every row in the table, so the restriction is not being used.

      the value comes from
      <h:inputText id="value" required="true" value="#{search.value}" />


      I thought that it might have been the actual query so I changed it to
      restrictions.add("username like concat(#{search.value},'%') ");


      Any Help?
      Thanks
      Sean.