We're updating the issue view to help you get more done. 

hibernate spatial - getSRID returning 0

Description

We are using Hibernate 5.0.7 under Wildfly 10.0.0 with Oracle 12c.

I have an entity mapping com.vividsolutions.jts.geom.Geometry to SDO_GEOMETRY using @org.hibernate.annotations.Type(type = "jts_geometry").
My database geometry value is MDSYS.SDO_GEOMETRY(3001,4979,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),MDSYS.SDO_ORDINATE_ARRAY(-90,50,200))

getSRID on the returned object returns 0 instead of 4979. getCoordinates returns the expected data so that part is working fine.

Casting to Point did not make a difference. Using geolatte_geometry instead of jts_geometry resulted in getSRID returning -1.

Dependencies: geolatte-geom 1.0.1, jts 1.13, slf4j, oracle ojdbc7
persistence.xml has <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect" />

Previously, getSRID worked as expected in hibernate 4.3 / wildfly 8 (same db).

Entity:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 @Entity @Table(name = "LOCN") public class Location { private Long id; private Geometry geometry; /** * no-arg Constructor */ public Location() { } /** * * @return id */ @Id @Column(name = "LOCN_ID", unique = true, nullable = false) public Long getId() { return this.id; } /** * * @param id */ public void setId(Long id) { this.id = id; } /** * * @return geometry */ @Column(name = "LOCN_GEOM") @org.hibernate.annotations.Type(type = "jts_geometry") public Geometry getGeometry() { return this.geometry; } /** * * @param geometry */ public void setGeometry(Geometry geometry) { this.geometry = geometry; } }

Test resource:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 @Path("/location") public class LocationResource { @EJB protected LocationDAO locationDAO; @GET public Response getLocation(@QueryParam("id") Long id) { Location location = locationDAO.read(id); String newline = "\n"; String returnString = "For location " + location.getId() + ":" + newline + "x = " + location.getGeometry().getCoordinates()[0].x + newline + "y = " + location.getGeometry().getCoordinates()[0].y + newline + "z = " + location.getGeometry().getCoordinates()[0].z + newline + "SRID = " + location.getGeometry().getSRID(); return Response.ok().entity(returnString).build(); } }

Create test record:
INSERT INTO LOCN (LOCN_ID, LOCN_GEOM)
VALUES (123456, MDSYS.SDO_GEOMETRY(3001,4979,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),MDSYS.SDO_ORDINATE_ARRAY(-90,50,200)))

GET location:
curl localhost:8080/webapp/location?id=123456
For location 123456:
x = -90.0
y = 50.0
z = 200.0
SRID = 0

Environment

Hibernate 5.0.7, Oracle 12c

Status

Assignee

Karel Maesen

Reporter

Dawn Lenz

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.0.7

Priority

Major