DataNucleus supports by default a large number of Java types. DataNucleus Spatial supports the storage and query of a number of different spatial data types, like points, polygons or lines. Spatial types like these are used to store geographic information like locations, rivers, cities, roads, etc. The datanucleus-geospatial plugin allows using spatial and traditional types simultaneously in persistent objects making DataNucleus a single interface to read and manipulate any business data.
The table below shows the currently supported Spatial SCO Java types in DataNucleus
Java Type | Spec. | DFG? | Persistent? | Proxied? | PK? | Plugin |
---|---|---|---|---|---|---|
oracle.spatial.geometry.JGeometry [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
com.vividsolutions.jts.geom.Geometry [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
com.vividsolutions.jts.geom.GeometryCollection [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
com.vividsolutions.jts.geom.LinearRing [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
com.vividsolutions.jts.geom.LineString [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
com.vividsolutions.jts.geom.MultiLineString [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
com.vividsolutions.jts.geom.MultiPoint [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
com.vividsolutions.jts.geom.MultiPolygon [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
com.vividsolutions.jts.geom.Point [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
com.vividsolutions.jts.geom.Polygon [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.Geometry [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.GeometryCollection [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.LinearRing [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.LineString [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.MultiLineString [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.MultiPoint [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.MultiPolygon [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.Point [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.Polygon [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.PGbox2d [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
org.postgis.PGbox3d [1] | ![]() |
![]() |
![]() |
![]() |
![]() |
datanucleus-geospatial |
The implementation of these spatial types follows the OGC Simple Feature specification, but adds further types where the datastores support them.
DataNucleus supports different combinations of geometry libraries and spatially enabled databases. These combinations are called mapping scenarios. Each of these scenarios has a different set of advantages (and drawbacks), some have restrictions that apply. The table below tries to give as much information as possible about the different scenarios.
One such mapping scenario, is to use the Java geometry types from JTS (Java Topology Suite) and PostGIS as datastore. The short name for this mapping scenario is jts2postgis. The following table lists all supported mapping scenarios.
Geometry Libraries | MySQL [1] | Oracle [2] [4] | PostgreSQL with PostGIS [3] [4] [5] |
---|---|---|---|
Oracle's JGeometry | ![]() |
![]() |
![]() |
Java Topology Suite (JTS) | ![]() |
![]() |
![]() |
PostGIS JDBC Geometries | ![]() |
![]() |
![]() |
This table lists all the spatial Java types that are currently supported. The JDBC type is the same for every Java type in a given database. It's SDO_GEOMETRY for Oracle, OTHER for PostGIS and BINARY for MySQL. When a type is supported by a database, the column type that is used for it, is listed after the icon. None of the types are proxied, this means that if you change an object field, you must reassign it to the owner object field to make sure changes are propagated to the database.
Geometry Library | Java Type | MySQL | Oracle | PostGIS |
---|---|---|---|---|
JGeometry | oracle.spatial.geometry.JGeometry | ![]() |
![]() |
![]() |
JTS | com.vividsolutions.jts.geom.Geometry | ![]() |
![]() |
![]() |
JTS | com.vividsolutions.jts.geom.GeometryCollection | ![]() |
![]() |
![]() |
JTS | com.vividsolutions.jts.geom.LinearRing | ![]() |
![]() |
![]() |
JTS | com.vividsolutions.jts.geom.LineString | ![]() |
![]() |
![]() |
JTS | com.vividsolutions.jts.geom.MultiLineString | ![]() |
![]() |
![]() |
JTS | com.vividsolutions.jts.geom.MultiPoint | ![]() |
![]() |
![]() |
JTS | com.vividsolutions.jts.geom.MultiPolygon | ![]() |
![]() |
![]() |
JTS | com.vividsolutions.jts.geom.Point | ![]() |
![]() |
![]() |
JTS | com.vividsolutions.jts.geom.Polygon | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.Geometry | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.GeometryCollection | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.LinearRing | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.LineString | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.MultiLineString | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.MultiPoint | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.MultiPolygon | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.Point | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.Polygon | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.PGbox2d | ![]() |
![]() |
![]() |
PostGIS-JDBC | org.postgis.PGbox3d | ![]() |
![]() |
![]() |
DataNucleus-Spatial has defined some metadata extensions that can be used to give additional information about the geometry types in use. The position of these tags in the meta-data determines their scope. If you use them inside a <field>-tag the values are only used for that field specifically, if you use them inside the <package>-tag the values are in effect for all (geometry) fields of all classes inside that package, etc.
<package name="org.datanucleus.samples.jtsgeometry"> <extension vendor-name="datanucleus" key="spatial-dimension" value="2"/> [1] <extension vendor-name="datanucleus" key="spatial-srid" value="4326"/> [1] <class name="SampleGeometry" detachable="true"> <field name="id"/> <field name="name"/> <field name="geom" persistence-modifier="persistent"> <extension vendor-name="datanucleus" key="mapping" value="no-userdata"/> [2] </field> </class> <class name="SampleGeometryCollectionM" table="samplejtsgeometrycollectionm" detachable="true"> <extension vendor-name="datanucleus" key="postgis-hasMeasure" value="true"/> [3] <field name="id"/> <field name="name"/> <field name="geom" persistence-modifier="persistent"/> </class> <class name="SampleGeometryCollection3D" table="samplejtsgeometrycollection3d" detachable="true"> <extension vendor-name="datanucleus" key="spatial-srid" value="-1"/> [1] <extension vendor-name="datanucleus" key="spatial-dimension" value="3"/> [1] <field name="id"/> <field name="name"/> <field name="geom" persistence-modifier="persistent"/> </class> </package>
DataNucleus-Spatial defines a set of functions that can be applied to spatial types in JDOQL queries. These functions follow the definitions in the OGC Simple Feature specification and are translated into appropriate SQL statements, provided the underlying database system implements the functions and the geometry object model accordingly. There are also some additional functions that are not defined OGC SF, most of them are database specific.
This set of more than eighty functions contains:
For a compelete list of all supported functions and usage examples, please see JDOQL : Spatial Methods.