I have a neo4j database, and one of the nodes in the database has the following:
<id>:91671 coordinates: point({srid:7203, x:-4.327197062, y:52.03857589}) description: "home"
I am trying to make a model of this in java - so:
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Property;
import org.neo4j.ogm.types.spatial.CartesianPoint2d;
@NodeEntity (label="Location")
public class Location
{
@Id @GeneratedValue
private Long id;
public Long getId()
{
return id;
}
@Property(name="description")
String description;
@Property(name="coordinates")
CartesianPoint2d coordinates; // problem is here
}
When I try to use ogm to map the node into the object, I get the following error:
org.neo4j.ogm.exception.core.InvalidPropertyFieldException: 'Location#coordinates' is not persistable as property but has not been marked as transient.
I have tried various other types for coordinates
, and have also tried to use a converter (based on the ogm documentation - see 3.10.2); but each time I get an error.
What is the correct way to do this mapping between a neo4j Point of srid 7203, and a type in java? Why does it say that it's not persistable, and what's my alternatives?
note: I am aware that my Points should probably be srid 4326 as I'm talking about latitudes and longitudes - I'm not sure why they're not - but let's solve the problem as-is for now
Please make sure you enabled the native types in ogm properties as
use-native-types=true
or in configuration builder
Configuration configuration = new Configuration.Builder()
.uri("bolt://neo4j:password@localhost")
.useNativeTypes() //this enables using the spatial and temporal data
.build() // types in ogm
and in your pojo use CartesianPoint2d/CartesianPoint3d or GeographicPoint2d/GeographicPoint3d depending on the data type you have in graph.
@Property(name="coordinates")
CartesianPoint2d coordinates;