-->
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.  [ 1 post ] 
Author Message
 Post subject: How to reverse engineer a PostGIS enabled database?
PostPosted: Tue Feb 23, 2016 3:49 am 
Newbie

Joined: Tue Feb 23, 2016 3:34 am
Posts: 5
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.


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

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.