This is more of a question but could be ultimately a bug...
So here is the story, trying to save a Geometry (as I understand Geography is not yet supported) into a MSSQL db. Here is the relevant mapping, which seems to create the table as expected:
{code} import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table;
import com.vividsolutions.jts.geom.Point;
@Entity @Table(name = "distance_holder") public class DistanceHolder {
@Id @GeneratedValue(strategy = GenerationType.AUTO) private long id;
@Column(name = "name") private String name;
@Column(columnDefinition = "Geometry") private Point position; {code}
But then how do I insert via jpa (spring-data-jpa in case it matters) to such a table:
{code} DistanceHolder holder1 = new DistanceHolder(); holder1.setName("Some-Street");
GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326); Coordinate coord1 = new Coordinate(46.977105, 28.874498); // that's my house coords Point someStreet = factory.createPoint(coord1); someStreet.setSRID(4326);
holder1. someStreet setPoint ( dacia53 someStreet ); {code}
The exception thrown is :
{code} com.microsoft.sqlserver.jdbc.SQLServerException: A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry":
System.ArgumentException: 24100: The spatial reference identifier (SRID) is not valid. SRIDs must be between 0 and 999999.
System.ArgumentException:
. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217) {code} |
|