title: Hibernate query by EnumType fails with Oracle (but works with MySQL)
body: <p>We have the following Java enum defined in Constants.java:</p>
  
  <pre><code>public enum ComponentType implements IsSerializable {
      NOC("NOC"),
      // other values not shown
      ;
  }
  </code></pre>
  
  <p>We have an Component class that has a field of type ComponentType:</p>
  
  <pre><code>public class Component implements Serializable {    
      private ComponentType type = null;
      // other code not shown
  }
  </code></pre>
  
  <p>We have a Component.hbm.xml Hibernate mapping file that maps the enum field to a column:</p>
  
  <pre><code>&lt;hibernate-mapping default-lazy="false"&gt;
      &lt;class name="our.package.Component" table="Component"&gt;
          &lt;property name="type" column="TYPE"&gt;
               &lt;type name="org.hibernate.type.EnumType"&gt;
                   &lt;param name="enumClass"&gt;our.package.Constants$ComponentType&lt;/param&gt;
                   &lt;param name="type"&gt;12&lt;/param&gt;
               &lt;/type&gt;
           &lt;/property&gt;
           &lt;!-- other mappings not shown --&gt;
        &lt;/class&gt;
   &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>We have a DAO with the following method to query any field for any value:</p>
  
  <pre><code>protected T loadByX(Class&lt;T&gt; entityClass, String fieldName, Object fieldValue) {
      T result = null;
      try {
          session = HibernateUtil.currentSession();
          result = (T) session.createCriteria(entityClass).add(Restrictions.eq(fieldName, fieldValue)).uniqueResult();
          session.close();
      }
      catch (HibernateException he) {
          // code not shown
      }
      return result;
  }
  </code></pre>
  
  <p>Then we have the following code that calls the DAO:</p>
  
  <pre><code>Component component = instanceOfComponentDao.loadByX(Component.class, "type", Constants.ComponentType.NOC);
  if (component == null) {
      //
      // SECTION A
      //
  }
  </code></pre>
  
  <p>This code all works when the database is MySQL.  In the COMPONENT table, there is one row with a type column having the value "NOC", and it gets returned by the call to loadByX() and the "SECTION A" code does not execute.</p>
  
  <p>However, this code doesn't work when the database is Oracle 11.  The COMPONENT table has one row with a type column having the value "NOC", but a null value is being returned by the call to loadByX() because the "SECTION A" code gets executed.</p>
  
  <p>Any idea what is wrong when using this code with Oracle?</p>