title: Spring + Hibernate, nested exception is org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters
body: <p>This code not work correctly: </p>
  
  <pre><code>getHibernateTemplate()
                  .find("from elephant.model.Setup s where s.settingName = ?",setupName);
  </code></pre>
  
  <p>Error: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1; nested exception is org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1</p>
  
  <p>If i changed code to: </p>
  
  <pre><code>getHibernateTemplate()
                  .find("from elephant.model.Setup s where s.settingName = :setupName",setupName);
  </code></pre>
  
  <p>I have the same error. How i can solve it ?</p>
  
  <p>later....</p>
  
  <p>i'll changed query like this:</p>
  
  <pre><code>.find("from elephant.model.Setup s where s.settingName = \"AutoAccessControl\"")
  </code></pre>
  
  <p>and now we have other error:</p>
  
  <pre><code>2563 [main] WARN org.hibernate.hql.QuerySplitter - no persistent classes found for query class: from elephant.model.Setup s where s.settingName = "AutoAccessControl"
  </code></pre>
  
  <p>my applicationContext.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
                             http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                             http://www.springframework.org/schema/tx
                             http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"&gt;
  
      &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
          &lt;property name="location" value="jdbc.properties" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="${jdbc.driverClassName}" /&gt;
          &lt;property name="url" value="${jdbc.url}" /&gt;
          &lt;property name="username" value="${jdbc.username}" /&gt;
          &lt;property name="password" value="${jdbc.password}" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="configLocation" value="classpath:/hibernate.cfg.xml" /&gt;
          &lt;property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" /&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven transaction-manager="txManager" /&gt;
  
      &lt;bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Office --&gt;
      &lt;bean id="OfficeDao" class="elephant.dao.impl.OfficeDao"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
      &lt;bean id="OfficeService" class="elephant.service.impl.OfficeService"&gt;
          &lt;property name="dao" ref="OfficeDao" /&gt;
      &lt;/bean&gt;
      &lt;!-- Office --&gt;
      &lt;!-- XMLFile --&gt;
      &lt;bean id="XMLFileDao" class="elephant.dao.impl.XMLFileDao"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
      &lt;bean id="XMLFileService" class="elephant.service.impl.XMLFileService"&gt;
          &lt;property name="dao" ref="XMLFileDao" /&gt;
      &lt;/bean&gt;
      &lt;!-- XMLFile --&gt;
      &lt;!-- AppointmentCategory --&gt;
      &lt;bean id="AppointmentCategoryDao" class="elephant.dao.impl.AppointmentCategoryDao"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
      &lt;bean id="AppointmentCategoryService" class="elephant.service.impl.AppointmentCategoryService"&gt;
          &lt;property name="dao" ref="AppointmentCategoryDao" /&gt;
      &lt;/bean&gt;
      &lt;!-- AppointmentCategory --&gt;
      &lt;!-- Setup --&gt;
      &lt;bean id="SetupDao" class="elephant.dao.impl.SetupDao"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
      &lt;bean id="SetupService" class="elephant.service.impl.SetupService"&gt;
          &lt;property name="dao" ref="SetupDao" /&gt;
      &lt;/bean&gt;
      &lt;!-- Setup --&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>my hibernate.cfg.xml</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
            "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;property name="hibernate.cache.use_second_level_cache"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.cache.use_query_cache"&gt;false&lt;/property&gt;
          &lt;property name="hibernate.cache.provider_class"&gt;org.hibernate.cache.EhCacheProvider&lt;/property&gt;
  
          &lt;property name="hibernate.transaction.flush_before_completion"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.transaction.auto_close_session"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
          &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.format_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.use_sql_comments"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.connection.charSet"&gt;true&lt;/property&gt;
  
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>my jdbc.properties</p>
  
  <pre><code>jdbc.driverClassName=org.postgresql.Driver
  jdbc.url=jdbc:postgresql://localhost:5432/hd_test
  jdbc.username=musr
  jdbc.password=mpwd
  hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
  </code></pre>