title: Creating a hibernate disjunction query programatically
body: <p>I have a chunk of java code which hard codes a hibernate disjunction query that looks like this </p>
  
  <pre><code>session = HibernateUtils.beginTransaction("outpatient");
          Criteria criteria = session.createCriteria(AugmentToken.class);
          session.beginTransaction();
          if (type == Constants.ICD9CPT) {
              criteria.add(Restrictions.disjunction()
                      .add(Restrictions.eq("codeType", "d"))
                      .add(Restrictions.eq("codeType", "p"))
                      .add(Restrictions.eq("codeType", "c")));
          } else if (type == Constants.EM) {
              criteria.add(Restrictions.disjunction()
                      .add(Restrictions.eq("codeType", "eros"))
                      .add(Restrictions.eq("codeType", "ehpi"))
                      .add(Restrictions.eq("codeType", "epe")));
          }
  </code></pre>
  
  <p>But this is not very elegant code.    What I would like to do is pass an array of codetypes to a method, and dynamically construct the dijunction criteria.   Every website I look at provides examples of disjunctive queries that look like the above, but this will not work for me because I don't want to hard code the construction of the restriction for the criteria since the number of code types can vary.   </p>
  
  <p>How do I do this?</p>
  
  <p>Thank you,</p>
  
  <p>Elliott</p>