title: Can't execute spatial query with spring and hibernate 5.0
body: <p>Here is my model</p>
  
  <pre><code>package objects;
  
  import com.fasterxml.jackson.databind.annotation.JsonSerialize;
  import com.vividsolutions.jts.geom.Geometry;
  import com.vividsolutions.jts.geom.Point;
  
  import javax.persistence.*;
  
  /**
   * Created by michael on 29/10/15.
   */
  @Entity
  public class Location {
  
      public Geometry getShape() {
          return shape;
      }
  
      public void setShape(Geometry shape) {
          this.shape = shape;
      }
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      private Geometry shape;
  
      public Location() {
      }
  
      @Override
      public String toString() {
          return "Location{" +
                  "id=" + id +
                  ", shape=" + shape +
                  '}';
      }
  }
  </code></pre>
  
  <p>And here is my controller</p>
  
  <pre><code>@RestController
  public class ObjectController {
  @Bean
  public Module jtsModule() {
      return new JtsModule();
  }
  
  @Autowired
  private LocationRepository repository;
  
  
  @RequestMapping(name = "/shape", method = RequestMethod.POST)
  public Collection&lt;Location&gt; createObjects() throws JsonProcessingException, ParseException {
      WKTReader wktReader = new WKTReader();
      Geometry geom = wktReader.read("POINT(-105 -105)");
      Geometry filter = wktReader.read("POLYGON((-107 39, -102 41, -107 41, -107 39))");
      ObjectMapper mapper = new ObjectMapper();
      mapper.registerModule(new JtsModule());
      Location location = new Location();
      GeometryFactory factory = new GeometryFactory();
      GeometricShapeFactory f = new GeometricShapeFactory(factory);
      location.setShape(geom);
      repository.save(location);
      f.setCentre(new Coordinate(50, 50));
      f.setSize(100);
      Polygon circle = f.createCircle();
  
      return repository.findWithin(filter);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is my repository</p>
  
  <pre><code>@Repository
  public interface LocationRepository extends CrudRepository&lt;Location, Long&gt; {
      @Query("select l from Location l where within(l.shape, ?) = true")
      List&lt;Location&gt; findWithin(Geometry geometry);
  }
  </code></pre>
  
  <p>And here is my config</p>
  
  <pre><code>spring:
    profiles: production
  
    datasource:
      platform: postgres
      url: jdbc:postgresql://192.168.99.100:5432/db
      username: user
      password: password
  
    database:
      driverClassName: org.postgresql.Driver
  
    jpa:
      database: POSTGRESQL
      platform: postgres
      show-sql: true
      ddl-auto: update
      hibernate:
        spatial:
          dialect:
            postgis: PostgisDialect
  ---
  
  spring:
    profiles: development
  
    datasource:
    platform: h2
    url: jdbc:h2:mem:test
  
    jpa:
      hibernate:
        show-sql: true
        spatial:
          dialect:
            h2geodb: GeoDBDialect
  </code></pre>
  
  <p>I'm using postgis and if I would remove query and only save geometries it would work fine. So I guess the spatial support is really working.</p>