I'm using mysql and wildly.
I want to look for points in a given polygon. My method looks like:
public Response getGeoJsonByBox(
@QueryParam("topLeftX") double topLeftX,
@QueryParam("bottomRightX") double bottomRightX,
@QueryParam("topLeftY") double topLeftY,
@QueryParam("bottomRightY") double bottomRightY) {
Envelope viewPort = new Envelope(topLeftX, bottomRightX, topLeftY, bottomRightY);
List<Stammdaten> stammdatenList = em.createQuery("select s from Stammdaten s where contains(:viewPort, s.coordinate) = true")
.setParameter("viewPort", viewPort)
.getResultList();
return stammdatenList;}
But I got the error:
Caused by: java.sql.SQLException: Geometry byte string must be little endian.
My Entity looks like:
@Entity
@Table(name = "partner_stammdaten")
@XmlRootElement(name = "stammdaten")
@XmlAccessorType(XmlAccessType.FIELD)
@NamedQuery(name = Stammdaten.all, query = "SELECT s from Stammdaten s")
public class Stammdaten extends GeoJson
{
public static final String all = "all";
public static final String viewPort = "getByViewPort";
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@XmlElement
private String name;
@XmlElement
private String strasse;
@XmlElement
private String hausnummer;
@XmlElement
private String ort;
@XmlElement
private String plz;
@XmlElement
private int rating;
private double longtitude;
private double latitude;
private Point coordinate;
private int placeId;
private String osmId;
public Stammdaten() {
}
//Getters/Setters and other implementation
}
So by the documentation of hibernate spatial the contains method is available for mysql. And both of the objects passed to my method are a type of geometry.
So I haven't any idea why this error happens.
Any idea on this would be nice.