Hibernate version: 2.1.6
Name and version of the database you are using: Oracle 9.2.0.5 Spatial
Hello,
I'm fairly new to Hibernate and read basically that it is possible to have custom UserTypes.
Nevertheless I wondered if anyone in this forum already has implemented a UserType for the Oracle spatial geometry objects.
There are two interesting types:
oracle.spatial.geometry.JGeometry which is the concrete usable geometry and oracle.sql.STRUCT which you can obtain from the database and convert it to JGeometry.
When using direct SQL you could use (from the Oracle Spatial JavaDoc):
/// reading a geometry from database
ResultSet rs = statement.executeQuery("SELECT geometry FROM states where name='Florida'");
STRUCT st = (oracle.sql.STRUCT) rs.getObject(1);
//convert STRUCT into geometry
JGeometry j_geom = JGeometry.load(st);
My first question: Has anyone implemented a UserType for this spatial scenario before I try? - If yes, I would appreciate some sample code for the UserType.
I see no point in reinventing the wheel and unfortunately I'm not sure if the Hibernate examples for Oracle Blobs work similar or same Oracle STRUCT.
My second one: Does it make more sense to map to STRUCT or implicitely do the JGeometry conversion?
Thanks a lot!
Cheers,
Michael
|