Hi
I get the wrong mapping type in Java using hibernatetools together hibernate-spatial, Postgres 9.3 postgis 2 for reverse engineering for spatial types like geometry(Polygon,4258) , geometry(Point,4258) .
I the postgres database I have a table with the following column
point_test | geometry(Point,4258) |
In the hibernate.cfg.xml I have the following line
<property name="hibernate.dialect">org.hibernate.spatial.dialect.postgis.PostgisDialect</property>
When I run “mvn install” I see the following the log
[DEBUG] No default type found for [sde_ar5.ar5_flate.point_test t:OTHER l:255 p:19 s:2 n:true id:false] falling back to [serializable]
[DEBUG] Sql type mismatch for Table: sde_ar5.ar5_flate column: point_test between DB and wanted hibernate type. Sql type set to 1111(OTHER) instead of -3(VARBINARY)
[DEBUG] Building property pointTest
In the java code I get the type
private Serializable pointTest;
and that should have been
private com.vividsolutions.jts.geom.Point pointTest;
Is this a bug or is a error a in the setup ?
Here is my pom.xml file used by maven.
Code:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.skogoglandskap</groupId>
<artifactId>java_reveng_hibernate</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hibernate-reveng</name>
<description>
This project contains common classes used by other
gpi_modules.
</description>
<properties>
<jdk.version>1.7</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<packageName>no.skogoglandskap.reveng.dao</packageName>
<jts.version>1.13</jts.version>
<hibernate-spatial.version>4.3</hibernate-spatial.version>
<hibernate-core.version>4.3.5.Final</hibernate-core.version>
<postgis-jdbc.version>1.5.2</postgis-jdbc.version>
<postgresql-version>9.1-901.jdbc4</postgresql-version>
<hibernate-tools.version>4.3.1.CR1</hibernate-tools.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Hibernate Spatial for postgis. This will include Hibernate Spatial
Core and JTS -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>${hibernate-spatial.version}</version>
</dependency>
<!-- the Postgis JDBC driver -->
<dependency>
<groupId>org.postgis</groupId>
<artifactId>postgis-jdbc</artifactId>
<version>${postgis-jdbc.version}</version>
</dependency>
<!-- the postgresql driver -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql-version}</version>
</dependency>
<!-- Hibernate uses slf4j for logging, for our purposes here use the simple
backend -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.11</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-core.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>${hibernate-tools.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>OSGEO GeoTools repo</id>
<url>http://download.osgeo.org/webdav/geotools</url>
</repository>
<repository>
<id>Hibernate Spatial repo</id>
<url>http://www.hibernatespatial.org/repository</url>
</repository>
<repository>
<id>jboss-public</id>
<name>JBoss Public Nexus Repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>Hibernate Spatial repo</id>
<url>http://www.hibernatespatial.org/repository</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<!-- <version>3.0</version> -->
<version>2.2</version>
<configuration>
<hibernatetool>
<annotationconfiguration
propertyfile="src/main/resources/${hibernate.properties}" />
<hbm2ddl update="true" create="true" export="false"
outputfilename="${hibernate.hbm2ddl.sqlfile}" format="true"
console="true" />
</hibernatetool>
</configuration>
<executions>
<execution>
<id>hbm2cfgxml</id>
<phase>generate-resources</phase>
<goals>
<goal>hbm2cfgxml</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2cfgxml</name>
<implementation>jdbcconfiguration</implementation>
</component>
</components>
<componentProperties>
<packagename>${packageName}</packagename>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2hbmxml</id>
<phase>generate-resources</phase>
<goals>
<goal>hbm2hbmxml</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2hbmxml</name>
<outputDirectory>target/classes</outputDirectory>
</component>
</components>
<componentProperties>
<packagename>${packageName}</packagename>
</componentProperties>
</configuration>
</execution>
<!-- used with hbm files -->
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>configuration</implementation>
</component>
</components>
<componentProperties>
<packagename>${packageName}</packagename>
<configurationfile>target/hibernate3/generated-mappings/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
</execution>
<!-- used with hbm giles -->
<execution>
<id>hbm2dao</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2dao</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2dao</name>
<implementation>configuration</implementation>
</component>
</components>
<componentProperties>
<packagename>${packageName}</packagename>
<configurationfile>target/hibernate3/generated-mappings/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql-version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>${hibernate-spatial.version}</version>
</dependency>
<dependency>
<groupId>org.postgis</groupId>
<artifactId>postgis-jdbc</artifactId>
<version>${postgis-jdbc.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-core.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>${hibernate-tools.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Thanks Lars