title: HQL - Remember that ordinal parameters are 1-based?
body: <p>I'm trying to match a hibernate entity via by DAO class, the first method works but the second 'findByMatchingName()' fails with the exception below. What's wrong with this clause '%?%'> ?</p>
  
  <pre><code>public class RunnerDaoImpl extends GenericDaoImpl implements RunnerDao
  {
      protected Class&lt;Runner&gt; getEntityClass() {
          return Runner.class;
      }
  
      // Works
      public List&lt;Runner&gt; findByExactName(String name)
      {
          return super.getHibernateTemplate().find("from Runner r where concat(r.firstname,' ',r.surname) LIKE =",new String[]{name});
      }
  
      // Fails
      public List&lt;Runner&gt; findByMatchingName(String name)
      {
          return super.getHibernateTemplate().find("from Runner r where concat(r.firstname,' ',r.surname) LIKE '%?%'",new String[]{name});
      }
  }
  </code></pre>
  
  <p>The exception</p>
  
  <pre><code>java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
      at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:79)
      at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:85)
      at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:421)
      at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:393)
      at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:918)
      at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:1)
      at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
      at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
      at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
      at ie.bhaa.dao.RunnerDaoImpl.findByName(RunnerDaoImpl.java:15)
      at ie.bhaa.dao.RunnerDaoTest.findRunnerByName(RunnerDaoTest.java:36)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
  </code></pre>