0 Replies Latest reply on Jul 16, 2010 1:00 PM by Lelo Pieri

    How to set default restrictions

    Lelo Pieri Newbie

      Hi All,


      I'm trying to set default restrictions on EntityQuery but it is not working.


      My goals is include the condition: parent is null


      If i can, I'd like to do not filter by path, just by parent.


      My code is:


      public class UploadedFile {
                
           private int id;
           private UploadedFile parent;
           private String path="";
           private int status;
           private Date uploadedDate;
           private String errorMsg;
           private Company company;
      ...
      //getters and setters
      }
      
      public class UploadedFileList extends EntityQuery<UploadedFile> {
      
           private static final long serialVersionUID = -1706808665658570124L;
      
           private static final String EJBQL = "select uploadedFile from UploadedFile uploadedFile";
      
      //     private static final String[] RESTRICTIONS = { "lower(uploadedFile.path) like lower(concat(#{reportsList.report.path},'%'))", 
      //          "uploadedFile.parent = #{null}"};
           private static final String[] RESTRICTIONS = { "lower(uploadedFile.path) like lower(concat(#{uploadedFileList.uploadedFiles.path},'%'))"};
      
           private UploadedFile uploadedFile = new UploadedFile();
      
           public UploadedFileList() {
                setEjbql(EJBQL);
                setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
      
                      //this restriction doesn't work
                List<ValueExpression> restrictions = new ArrayList<ValueExpression>();
                restrictions.add(createValueExpression("uploadedFile.parent = #{null}"));
                setRestrictions(restrictions);
      
                setMaxResults(25);
           }
      
           public UploadedFile getUploadedFiles() {
                return uploadedFile;
           }
      }



      Thanks for all.


      Pieri