title: Hibernate SetParameter driving me nuts
body: <p>This works</p>
  
  <pre><code>hql = "from State where StateCode like 'T%'";
  Query query = session.createQuery(hql);
  </code></pre>
  
  <p>This does not</p>
  
  <pre><code>hql = "from State where StateCode like :StateCode";
  Query query = session.createQuery(hql);
  query.setParameter("StateCode", "T%");
  </code></pre>
  
  <p>I get this</p>
  
  <pre><code>1568 [main] DEBUG org.hibernate.hql.ast.ErrorCounter  - throwQueryException() : no errors
  1596 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker  - select &lt;&lt; begin [level=1, statement=select]
  1608 [main] DEBUG org.hibernate.hql.ast.tree.FromElement  - FromClause{level=1} :  com.kencogroup.kkms.models.State (no alias) -&gt; state0_
  1610 [main] DEBUG org.hibernate.hql.ast.tree.FromReferenceNode  - Resolved :  {synthetic-alias} -&gt; {synthetic-alias}
  1611 [main] DEBUG org.hibernate.hql.ast.tree.DotNode  - getDataType() : StateCode -&gt; org.hibernate.type.StringType@a39137
  1611 [main] DEBUG org.hibernate.hql.ast.tree.FromReferenceNode  - Resolved :  {synthetic-alias}.StateCode -&gt; state0_.StateCode
  SELECT Exception: java.lang.reflect.UndeclaredThrowableException
  </code></pre>
  
  <p>Notice the <code>UndeclaredThrowableException</code> exception.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>The database is SQL Server 2008 if that helps.  But like I said, other queries work just fine.  </p>
  
  <p>Thanks</p>