0 Replies Latest reply on Oct 15, 2015 6:00 PM by mrkite79

    Querying on an audited entity with conditions

    mrkite79

      Hi all, I am new to envers and I've got a question for you.

       

      I've got an audited entity Atricle with some attributes (id, title, category, state (it can be: validated, published, draft), date)

       

      When an article changes state (e.g. from draft to validated or from validated to published) I audit that change.

       

      I've got a search form where i set values category and date and I want to search all revisioned articles in the state "published" where category and/or date is the one I set in the search form.

       

      How can I do this using AuditReaderFactory?

       

      I've got this code in my Action class

       

      AuditReader reader = AuditReaderFactory.get(getCurrentSession());  
            
          List<Article> articles = new ArrayList<Article>();
      
        articles = (ArrayList<Articles>)reader.createQuery().forEntitiesAtRevision(Article.class, 100)
        .add(AuditEntity.relatedId("state").eq(MyConstants.published_state))
        .getResultList();
      

       

      So I can get all revisioned articles in the state "published" but how can I add request parameters?

       

      I hope I was clear

      Thanks