text: Q:
  
  Solving java.lang.NoSuchMethodError: org.hibernate.criterion.CriteriaQuery.getFactory()
  
  I have the following hibernate query:
      @SuppressWarnings("unchecked")
      @Override
      public List<Admin> getAffectedAdmins(String wktFilter) {
          WKTReader fromText = new WKTReader();
          Geometry filter = null;
  
          try {
              filter = fromText.read(wktFilter);
              System.out.println("Filter = " + filter);
          } catch (ParseException e) {
              e.printStackTrace();
          }
  
          hibernateTemplate = new HibernateTemplate(sessionFactory);
          List<Admin> admins = new ArrayList<Admin>();
          admins =  (List<Admin>) hibernateTemplate.findByCriteria(
                  DetachedCriteria.forClass(Admin.class)
                  .add(SpatialRestrictions.intersects("geom", filter)));
  
          return admins;
      }
  
  When I execute the above method, the following exception is thrown:
  java.lang.NoSuchMethodError: org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;
  The relevant section in my spring configuration file is shown below:
      <bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
          p:location="/WEB-INF/jdbc.properties" />
  
      <bean id="dataSource"
          class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
          p:password="${jdbc.password}" />
  
      <bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
          <property name="dataSource" ref="dataSource" />
          <property name="configLocation">
              <value>classpath:hibernate.cfg.xml</value>
          </property>
          <property name="configurationClass">
              <value>org.hibernate.cfg.AnnotationConfiguration</value>
          </property>
          <property name="hibernateProperties">
              <props>
                  <prop key="hibernate.dialect">${jdbc.dialect}</prop>
                  <prop key="hibernate.show_sql">true</prop>
              </props>
          </property>
      </bean>
  
      <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager">
          <property name="sessionFactory" ref="sessionFactory" />
      </bean>
  
  My environment: Hibernate-3.6.10.FINAL, Spring 3.1.2.RELEASE, Hibernate Spatial 4.x, PostGIS JDBC 1.5.2 and PostgreSQL 8.4-702.jdbc3. 
  Any idea on what I may be doing wrong will be highly appreciated.
  UPDATE: This works for simple queries; queries that do not involve spatial data. So, I guess its the spatial component that has issues.
  UPDATE: pom.xml, I've included the relevant sections in my POM file.
  <properties>
          <spring.version>3.1.2.RELEASE</spring.version>
      </properties>
  
      <dependencies>
          <dependency>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>2.5.1</version>
          </dependency>
  
          <dependency>
              <groupId>org.hibernate</groupId>
              <artifactId>hibernate-core</artifactId>
              <version>3.6.10.Final</version>
          </dependency>
  
          <dependency>
              <groupId>org.hibernate</groupId>
              <artifactId>hibernate-spatial</artifactId>
              <version>4.0-M1</version>
          </dependency>
  
          <dependency>
              <groupId>org.postgis</groupId>
              <artifactId>postgis-jdbc</artifactId>
              <version>${hibernate-spatial.version}</version>
              <exclusions>
                  <exclusion>
                      <artifactId>postgis-jdbc</artifactId>
                      <groupId>org.postgis</groupId>
                  </exclusion>
              </exclusions> 
          </dependency>
  
          <dependency>
              <groupId>org.postgis</groupId>
              <artifactId>postgis-jdbc</artifactId>
              <version>1.5.2</version>
          </dependency>
  
          <dependency>
              <groupId>org.hibernate</groupId>
              <artifactId>hibernate-entitymanager</artifactId>
              <version>3.6.10.Final</version>
          </dependency>
  
          <dependency>
              <groupId>postgresql</groupId>
              <artifactId>postgresql</artifactId>
              <version>8.4-702.jdbc3</version>
          </dependency>
  
          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
              <version>1.6.6</version>
          </dependency>
  
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
          </dependency>
  
  A:
  
  My environment: Hibernate-3.6.10.FINAL, Hibernate Spatial 4.x
  
  But http://www.hibernatespatial.org/:
  
  Compatibility with Hibernate ORM
  
  Hibernate Spatial version 1.0 is compatible with Hibernate 3.2.x - 3.5.x
  Hibernate Spatial version 1.1.x is compatible with Hibernate 3.6.x
  Hibernate Spatial version 4.0 is compatible with Hibernate 4.x
  
  