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!