title: Case sensitive Search in Hibernate Criteria
body: <p>I'm using Hibernate 3 with SQL Server 2008. I want to do case sensitive search in Hibernate Criteria. I'm not able to achieve it. My code is as below:</p>
  
  <pre><code>Criteria criteria = session.createCriteria(User.class); /*line 1*/
  criteria.add(Restrictions.eq("userName", userName));    /*line 2*/
  </code></pre>
  
  <p>I have a class <strong>User.java</strong> which contains a <code>String userName</code>.</p>
  
  <p>DB Entries:</p>
  
  <pre><code>id | user_name
  --------------
  1  | abc
  2  | xyz
  </code></pre>
  
  <p>Now, if I pass <code>"abc"</code> as <code>userName</code> in line 2, then it should return the first record from the db. But if I pass <code>"Abc"</code>, <code>"ABC"</code>, <code>"aBC"</code> etc. as <code>userName</code> in line 2, no records should be fetched.</p>
  
  <p>I've visited this <a href="https://stackoverflow.com/questions/9066143/case-sensitive-on-restrictions-equals-id-in-hibernate-restrictions">link</a> but it's not helpful to me as I don't want to use collation with hql or with SQL Server. I'm open to use collation with <code>Criteria</code> but don't know how to do it.</p>