title: Hibernate Spatial Create Geometry object
body: <p>I am developing an location app with oracle spatial in Java. I am using hibernate 4.0 spatial for orm layer. I am new in spatial and i couldn't find best practise for hibernate spatial. My database model following;</p>
  
  <pre><code>CREATE TABLE SYSTEM.POI  (
      POI_ID          INTEGER,
      SERVICE_ID      INTEGER,
      POI_NAME        VARCHAR2(255 CHAR),
      DESCRIPTION     VARCHAR2(1023 CHAR),
      CATEGORY        VARCHAR2(127 CHAR),
      ADDRESS         VARCHAR2(4000 CHAR),
      MOBILE_PHONE    VARCHAR2(15 CHAR),
      FIXED_PHONE     VARCHAR2(15 CHAR),
      BUSINESS_HOURS  VARCHAR2(1023 CHAR),
      SHAPE           SDO_GEOMETRY  
  )
  </code></pre>
  
  <p>insert statement is following;</p>
  
  <pre><code>INSERT INTO SYSTEM.POI (SERVICE_ID, POI_NAME, DESCRIPTION, CATEGORY, ADDRESS, MOBILE_PHONE, FIXED_PHONE, BUSINESS_HOURS, SHAPE)
  VALUES(
          '1320',
          'PO-Kral Petrol Ürünleri San ve Tic. Ltd. şti.',
          'Camilerimiz',
          'CAMI',
          'İSLİCE MAHALLESİ DERE SOKAK NO:5',
          '2762151093',
          '5552552343',
          'Hafta içi  09:00 - 17:00, haftasonu 09:00 - 13:00 açık',
          SDO_GEOMETRY(
              2001, 
              3785,
              SDO_POINT_TYPE(28.90762, 41.1521, NULL),
              NULL,
              NULL
          )
        );  
  </code></pre>
  
  <p>entity model is following i'm sharing just sdo_geometry object;</p>
  
  <pre><code>import com.vividsolutions.jts.geom.Geometry;
  
  ...
  
      @Column(name="SHAPE")
      @Type(type = "org.hibernatespatial.GeometryUserType")
      private Geometry shape;
  
      public Geometry getShape() {
        return shape;
      }
  
      public void setShape(Geometry shape) {
        this.shape = shape;
      }
  </code></pre>
  
  <p>How can i fill this spahe object with dynamic parameters. For example;</p>
  
  <pre><code>  SDO_GEOMETRY(
                  2001,  --&gt; sdo_gtype
                  3785,  --&gt; sdo_srid
                  SDO_POINT_TYPE(28.90762, 41.1521, NULL),  --&gt; sdo_point
                  NULL,  --&gt; sdo_elem_info
                  NULL   --&gt; sdo_ordinates
              )
  </code></pre>
  
  <p>How to pass sdo_gtype,sdo_srid,sdo_point_type parameters to geometry object dynamically?</p>