title: Hibernate spatial jpa query not working
body: <p>I have written spatial query to find nearest point from a location. But hibernate get exception. <strong>My Application with Spring boot 1.5.7</strong></p>
  
  <pre><code>@Repository
  @Transactional(readOnly = true)
  public interface PlaceRepository extends JpaRepository&lt;PlaceEntity, Long&gt; {
      PlaceEntity findByCode(String code);
      PlaceEntity findByName(String name);
      @Query("select l from PlaceEntity l where within(l.location, :filter) = true")
      List&lt;PlaceEntity&gt; findLocationWithin(Geometry filter);
  }
  </code></pre>
  
  <p>Here my entity class param</p>
  
  <pre><code>@Data
  @Entity(name = "Place")
  public class PlaceEntity extends BaseEntity {
  
  @Type(type = "org.hibernate.spatial.GeometryType")
  @Column(name = "LOCATION",columnDefinition = "POINT")
      private Point location;
  }
  </code></pre>
  
  <p>Others Params are</p>
  
  <pre><code>@Id
  @GeneratedValue
  @Column(name = "ID")
  private long id;
  @Column(name = "NAME")
  private String name;
  @Column(name = "CODE")
  private String code;
  @Column(name = "LONGITUDE")
  private Double longitude;
  @Column(name = "LATITUDE")
  private Double latitude;
  </code></pre>
  
  <p>Here my build.gradle.   </p>
  
  <pre><code>compile('org.springframework.boot:spring-boot-starter-actuator')
  compile('org.springframework.boot:spring-boot-starter-data-jpa')
  compile('org.hibernate:hibernate-core:4.3.0.Final')
  compile("org.hibernate:hibernate-spatial:4.3")
  compile("org.hibernate:hibernate-entitymanager:4.3.0.Final")
  compile('mysql:mysql-connector-java')
  compile('org.projectlombok:lombok:1.14.8')
  compile('org.springframework.boot:spring-boot-starter-web')
  compile('com.vividsolutions:jts:1.13')
  testCompile('org.springframework.boot:spring-boot-starter-test')
  </code></pre>
  
  <p>Configuration</p>
  
  <pre><code>@EnableWebMvc
  @Configuration
  public class AppConfig {
  
  }
  </code></pre>
  
  <p>But when I deploy server then get exception.</p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pathController': Unsatisfied dependency expressed through field 'pathService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pathServiceImpl': Unsatisfied dependency expressed through field 'placeRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'placeRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.fm.assignment.core.dao.PlaceRepository.findLocationWithin(com.vividsolutions.jts.geom.Geometry)!
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
  
  
  
  Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pathServiceImpl': Unsatisfied dependency expressed through field 'placeRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'placeRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.fm.assignment.core.dao.PlaceRepository.findLocationWithin(com.vividsolutions.jts.geom.Geometry)!
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:58
  
  
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'placeRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.fm.assignment.core.dao.PlaceRepository.findLocationWithin(com.vividsolutions.jts.geom.Geometry)!
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
  
  
  
  Caused by: java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.fm.assignment.core.dao.PlaceRepository.findLocationWithin(com.vividsolutions.jts.geom.Geometry)!
          at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:92)
          at org.springframework.data.jpa.repository.query.SimpleJpaQuery.&lt;init&gt;(SimpleJpaQuery.java:62)
  
  
  Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: PlaceEntity is not mapped [select l from PlaceEntity l where within(l.location, :filter) = true]
          at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750)
          at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)
  
  
  
  Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: PlaceEntity is not mapped [select l from PlaceEntity l where within(l.location, :filter) = true]
          at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:96)
          at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120)
  
  
  
  
  Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: PlaceEntity is not mapped
          at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:189)
          at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:109)
          at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:95)
  </code></pre>
  
  <p><strong>Is there any mistake from my configuration?</strong></p>