-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: How to start with hibernate spatial 5.1 with postgis 2.1
PostPosted: Mon Apr 11, 2016 9:41 am 
Newbie

Joined: Mon Apr 11, 2016 9:31 am
Posts: 2
I am new in hibernate spatial ! I just don't know how to build a maven project with hibernate spatial 5,and I also can't not find any document for it ! anybody can help me?

besides,I wanna know whether hibernate tool can support newest version of hibernate spatial?


Top
 Profile  
 
 Post subject: Re: how to start hibernate spatial 5.1 with postgis 2.1
PostPosted: Mon Apr 11, 2016 9:50 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The reference documentation is a good start.

There's also an example in the documentation tests.


Top
 Profile  
 
 Post subject: Re: how to start hibernate spatial 5.1 with postgis 2.1
PostPosted: Thu Apr 14, 2016 7:37 am 
Newbie

Joined: Mon Apr 11, 2016 9:31 am
Posts: 2
mihalcea_vlad wrote:
The reference documentation is a good start.

There's also an example in the documentation tests.



Thank you very much!
With you help, I finally figure it out. Now I post my code below:

[1] softwares:
postgresql-9.4.1-3-windows-x64
postgis_2_2_pg94
<hibernate.version>4.3.8.Final</hibernate.version>

[2]dependencies
Code:
<dependency>
         <groupId>com.vividsolutions</groupId>
         <artifactId>jts</artifactId>
         <version>1.12</version>
      </dependency>   
      <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
      <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-spatial</artifactId>
            <version>4.3</version>
        </dependency>


[3]db.properties
Code:
hibernate.show_sql=true
hibernate.format_sql=false
hibernate.cache.use_second_level_cache=false
hibernate.cache.use_query_cache=false
hibernate.hbm2ddl.auto=none
jdbc.maxPoolSize=30
jdbc.minPoolSize=5
jdbc.initialPoolSize=10
jdbc.acquireIncrement=10
jdbc.maxStatements=500
jdbc.maxIdleTime=300
jdbc.idleConnectionTestPeriod=60
jdbc.acquireRetryAttempts=1000


hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect
jdbc.driverClass=org.postgresql.Driver
jdbc.jdbcUrl=jdbc\:postgresql\://127.0.0.1\:5432/gc
jdbc.user=postgres
jdbc.password=123


[4]mapping file
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2016-4-9 10:15:07 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
    <class name="com.lgeo.gc.dataprocess.model.GcDm" table="cities" schema="public">
        <id name="id" type="string">
            <column name="id" length="32" />
            <generator class="assigned" />
        </id>
        <property name="addname" type="string">
            <column name="name" length="100" />
        </property>
        <property name="geom" type="org.hibernate.spatial.GeometryType">
            <column name="the_geom" />
        </property>
    </class>
</hibernate-mapping>

[5] Model class
Code:
package com.lgeo.gc.dataprocess.model;

import org.hibernate.annotations.Type;

import com.vividsolutions.jts.geom.Point;

// Generated 2016-4-9 10:15:07 by Hibernate Tools 3.4.0.CR1

/**
* GcAddr generated by hbm2java
*/
public class GcDm implements java.io.Serializable {
   
   private String id;
   private String addname;   
   private Point geom;
   

   public GcDm() {
   }


   public GcDm(String id, String addname, Point geom) {
      super();
      this.id = id;
      this.addname = addname;
      this.geom = geom;
   }


   public String getId() {
      return id;
   }


   public void setId(String id) {
      this.id = id;
   }


   public String getAddname() {
      return addname;
   }


   public void setAddname(String addname) {
      this.addname = addname;
   }


   public Point getGeom() {
      return geom;
   }


   public void setGeom(Point geom) {
      this.geom = geom;
   }

   

}

[6] Finaly
With HibernateDaoSupport class , I can add,update and delete Geometry Object!

Hope it helpful.

Thanks againt!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.