Hi everyone, this is my set up:
. PostgreSQL 9.3
. PostGIS 2.1.4
. Eclipse Mars
. Hibernate 5.0.7
. Hibernate Spatial 5.0.7
My .cfg.xml file opens with:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">the_pass</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/the_db</property>
<property name="hibernate.connection.username">me</property>
<property name="hibernate.default_schema">the_schema</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.dialect">org.hibernate.spatial.dialect.postgis.PostgisDialect"</property>
<!-- "Import" the mapping resources here -->
In the reveng.xml file, the tables including geometry type fields are explicitly declared with table-filter elements:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
[...]
<table-filter match-name="coordinates"></table-filter>
<table-filter match-name="polygon"></table-filter>
</hibernate-reverse-engineering>
The Hibernate code generation configuration is creating POJOs with this kind of properties and methods for geometry type fields:
Code:
private Serializable geom;
public Serializable getGeom() {
return this.geom;
}
public void setGeom(Serializable geom) {
this.geom = geom;
}
In the
Hibernate Spatial tutorial, geometry fields are mapped to JTS types, such as (
com.vividsolutions.jts.geom.Point). Therefore with this code it is not possible to follow the mechanisms proposed there to retrieve/update spatial fields.
Is it possible to tweak the Hibernate configuration somehow for it to generate mappings from spatial fields to JTS types? Or must these generated
Serializable properties be used instead?
Thank you.