title: Hibernate comparing value(or parts of) to 2 columns
body: <p>I have 2 columns name: name, surname
  I have a search value called search. I want to be able to search on the fullname for example: john doe. (with the space). So far I got it working with only name, or surname by typing in john or doe. </p>
  
  <p>This is what I tried for the fullname:</p>
  
  <pre><code>Criterion fullname = Restrictions.and(Restrictions.like("name",  search).ignoreCase(),
                  Restrictions.like("surname", search).ignoreCase());
  </code></pre>
  
  <p>Full part:</p>
  
  <pre><code> Private List&lt;Users&gt; getSearch(String search) {
              List&lt;Users&gt; users = new ArrayList&lt;Users&gt;();
              Session dbSession = HibernateUtil.getSessionFactory().getCurrentSession();
              try {
                  Transaction tx = dbSession.beginTransaction();
                  Criteria cr = dbSession.createCriteria(Users.class);
                  Criterion name = Restrictions.or(Restrictions.like("name", search).ignoreCase(),
                  Restrictions.like("surname", search).ignoreCase());
                  Criterion fullname = Restrictions.and(Restrictions.like("name",  search).ignoreCase(),
                      Restrictions.like("surname", search).ignoreCase());         
  
                  Disjunction disjunction = Restrictions.disjunction();
                  disjunction.add(name);
                  disjunction.add(fullname);
                  cr.add(disjunction);
                  users = (List&lt;Users&gt;) cr.list();
                  tx.commit();
              } catch (HibernateException he) {
              }
              return users;
          }
  </code></pre>