title: How to do polymorphic queries with executeQuery() in grails?
body: <p>Why doesn't this polymorphic query work? </p>
  
  <pre><code>    String hql = """
                     FROM User u
                     WHERE
                     u.type.class = :typeClass
                  """
  
      return User.executeQuery(hql, [typeClass:Super])
  </code></pre>
  
  <p>all i get is the following exception:</p>
  
  <pre><code>Stacktrace follows:
  java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.Integer
  ....
  </code></pre>
  
  <p><strong>Update</strong>
  The error only seems to occur when i try to add the class as a named argument. eg, i dont get an error with this code:</p>
  
  <pre><code>    String hql = """
                     FROM User u
                     WHERE
                     u.type.class = Super
                  """
  
      return User.executeQuery(hql)
  </code></pre>
  
  <p><strong>Update2</strong></p>
  
  <p>This issue has baffled me. And now i don't care to use any more time on it. This is what i ended up with doing:</p>
  
  <pre><code>    def typeClass = Super.class.name
  
      String hql = """
                     FROM User u
                     WHERE
                     u.type.class = $typeClass
                  """
  
      return UserMedia.executeQuery(hql)
  </code></pre>
  
  <p>Really strange, no matter what i did when trying to pass the <code>class</code> or <code>class.name</code> i always would get the error. With and without multiline groovy string.</p>