title: Querying on enum's method in Hiberate Criteria API
body: <p>I have an <code>@Entity</code> which has an <code>@Enumerated</code> field mapped to it:</p>
  
  <pre><code>@Entity
  @Table
  public class Device implements Serializable {
  
      @Id
      @GeneratedValue
      private Long id;
      @Enumerated(EnumType.STRING)
      private DeviceType typeOfDevice;
  
      [....]
  
  }
  </code></pre>
  
  <p><code>DeviceType</code> is a typical java 5 enum:</p>
  
  <pre><code>public enum DeviceType {
    MOBILE(true), EMAIL(false);
    private final boolean fubar;
  
    private DeviceType(boolean fubar) {
      this.fubar= fubar;
    }
  
    public boolean isFubar() {
      return fubar;
    }
  }
  </code></pre>
  
  <p>How can i query for <code>Device</code> entities which have <code>typeOfDevice.isFubar() == true</code>?</p>
  
  <pre><code>return factory.getCurrentSession().createCriteria(Device.class).
         add(Restrictions.eq("typeOfDevice.isFubar", true)).list();
  </code></pre>
  
  <p>isn't doing the job as well as :</p>
  
  <pre><code>return factory.getCurrentSession().createCriteria(Device.class).
         createCriteria("typeOfDevice").add(Restrictions.eq("fubar", true)).list();
  </code></pre>