| /trunk/hibernate-spatial-maven/pom.xml |
|---|
| 6,7 → 6,7 |
| <modelVersion>4.0.0</modelVersion> |
| <groupId>org.hibernatespatial</groupId> |
| <artifactId>hibernate-spatial-maven</artifactId> |
| <version>1.1.1-SNAPSHOT</version> |
| <version>4.0-M1</version> |
| <name>Hibernate Spatial</name> |
| <description> |
| This is the Maven parent project for all Hibernate Spatial |
| 86,16 → 86,7 |
| </executions> |
| </plugin> |
| <!-- Release plugin --> |
| <plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-release-plugin</artifactId> |
| <version>2.2.2</version> |
| <configuration> |
| <autoVersionSubmodules>true</autoVersionSubmodules> |
| <tagBase>https://svn.apache.org/repos/asf/maven/components/releases</tagBase> |
| </configuration> |
| </plugin> |
| </plugins> |
| 104,13 → 95,13 |
| <scm> |
| <connection> |
| scm:svn:http://www.hibernatespatial.org/svn/hibernate-spatial/trunk/hibernate-spatial-maven |
| scm:git:git://github.com/maesenka/hibernate-core.git |
| </connection> |
| <developerConnection> |
| scm:svn:https://intra.geovise.com/svn/hibernate-spatial/trunk/hibernate-spatial-maven |
| scm:git:git@github.com:maesenka/hibernate-core.git |
| </developerConnection> |
| <url> |
| <![CDATA[ http://www.hibernatespatial.org/websvn/listing.php?repname=hibernate-spatial&path=/trunk/${project.artifactId}/rev=0&sc=0]]> |
| <![CDATA[ https://github.com/maesenka/hibernate-core]]> |
| </url> |
| </scm> |
| 415,7 → 406,7 |
| </properties> |
| </profile> |
| <!-- Oracle --> |
| <!-- Oracle 10g--> |
| <profile> |
| <id>oracle10g</id> |
| <dependencies> |
| 432,11 → 423,9 |
| </dependency> |
| <dependency> |
| <groupId>com.oracle.jdbc</groupId> |
| <!--<artifactId>ojdbc14</artifactId>--> |
| <artifactId>ojdbc6</artifactId> |
| <artifactId>ojdbc14</artifactId> |
| <version>10.2.0.1.0</version> |
| <scope>provided</scope> |
| <!--<version>10.2.0.1.0</version>--> |
| <version>[11.1.0.6.0,)</version> |
| </dependency> |
| </dependencies> |
| <properties> |
| 448,6 → 437,37 |
| </properties> |
| </profile> |
| <!-- Oracle 11g --> |
| <profile> |
| <id>oracle11g</id> |
| <dependencies> |
| <dependency> |
| <groupId>${project.groupId}</groupId> |
| <artifactId>hibernate-spatial-oracle</artifactId> |
| <version>${project.version}</version> |
| </dependency> |
| <dependency> |
| <groupId>${project.groupId}</groupId> |
| <artifactId>hibernate-spatial-oracle</artifactId> |
| <version>${project.version}</version> |
| <classifier>tests</classifier> |
| </dependency> |
| <dependency> |
| <groupId>com.oracle.jdbc</groupId> |
| <artifactId>ojdbc6</artifactId> |
| <scope>provided</scope> |
| <version>[11.1.0.6.0,)</version> |
| </dependency> |
| </dependencies> |
| <properties> |
| <db.dialect>org.hibernatespatial.oracle.OracleSpatial10gDialect</db.dialect> |
| <jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver> |
| <jdbc.url>jdbc:oracle:thin:@oracle11g.geovise.com:1521/orcl11g.geovise.com</jdbc.url> |
| <jdbc.user>HBS</jdbc.user> |
| <jdbc.pass>HBS</jdbc.pass> |
| </properties> |
| </profile> |
| </profiles> |
| /trunk/hibernate-spatial/src/site/site.xml |
|---|
| 43,26 → 43,25 |
| <menu name="Overview" inherit="top"> |
| <item name="Introduction" href="index.html"/> |
| <item name="Usage" href="usage.html"/> |
| <item name="Road Map" href="roadmap.html"/> |
| </menu> |
| <menu name="Getting Hibernate Spatial" inherit="top"> |
| <item name="Releases" href="download.html"/> |
| <item name="Release Notes" href="release_notes.html"/> |
| <item name="Sources" href="source-repository.html"/> |
| <item name="License" href="license.html"/> |
| <item name="Source code insight" |
| href="insight.html"/> |
| </menu> |
| <menu name="Documentation" inherit="top"> |
| <item name="Tutorial" href="tutorial.html"/> |
| <item name="Tutorial (1.x)" href="tutorial.html"/> |
| <item name="Tutorial (4.x)" href="tutorial-hs4.html"/> |
| <item name="Maven Quick Start" href="mavenquick.html"/> |
| <item name="Configuring providers" href="providers.html"/> |
| <item name="Configuring providers (1.x)" href="providers.html"/> |
| <item name="Getting Help" href="gettinghelp.html"/> |
| <item name="JavaDocs" href="apidocs/index.html"/> |
| <item name="JavaDocs (1.x)" href="apidocs/index.html"/> |
| <item name="JavaDocs (4.x)" href="apidocs-hs4/index.html"/> |
| </menu> |
| <menu name="Providers" inherit="top"> |
| <menu name="Providers (HS 1.x only)" inherit="top"> |
| <item name="Oracle10g" href="hibernate-spatial-oracle"/> |
| <item name="Postgresql" href="hibernate-spatial-postgis"/> |
| <item name="Microsft SQL Server" href="hibernate-spatial-sqlserver"/> |
| /trunk/hibernate-spatial/src/site/xdoc/mavenquick.xml |
|---|
| 33,7 → 33,8 |
| </properties> |
| <body> |
| <section name="Maven Quick Start"> |
| <section name="Maven Quick Start for HS 4.x"> |
| <p>If you use maven for your project, it's very easy to start using Hibernate Spatial.</p> |
| <p>First, add the Hibernate Spatial and GeoTools repositories to you pom.xml |
| </p> |
| 49,6 → 50,45 |
| <id>Hibernate Spatial repo</id> |
| <url>http://www.hibernatespatial.org/repository</url> |
| </repository> |
| </repositories> |
| ... |
| ]]> |
| </source> |
| <p>Secondly, add the Hibernate Spatial as a dependency.</p> |
| <source> |
| <![CDATA[ |
| ... |
| <dependencies> |
| ... |
| <dependency> |
| <groupId>org.hibernate</groupId> |
| <artifactId>hibernate-spatial</artifactId> |
| <version>4.0-M1</version> |
| </dependency> |
| ... |
| </dependencies> |
| ... |
| ]]> |
| </source> |
| </section> |
| <section name="Maven Quick Start for HS 1.x"> |
| <p>If you use maven for your project, it's very easy to start using Hibernate Spatial.</p> |
| <p>First, add the Hibernate Spatial and GeoTools repositories to you pom.xml |
| </p> |
| <source> |
| <![CDATA[ |
| ... |
| <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> |
| </repositories> |
| ... |
| /trunk/hibernate-spatial/src/site/xdoc/tutorial.xml |
|---|
| 14,7 → 14,7 |
| <section name="Introduction"> |
| <p> |
| This tutorial gives a quick overview of how to get |
| Hibernate Spatial working. We will develop a simple |
| Hibernate Spatial 1.x working. We will develop a simple |
| application that stores, and retrieves some |
| simple data objects. The data objects are "special" in |
| that they have a property of type Geometry. |
| /trunk/hibernate-spatial/src/site/xdoc/usage.xml |
|---|
| 6,9 → 6,84 |
| <body> |
| <section name="Installing Hibernate Spatial"> |
| <section name="Hibernate Spatial 4.x"> |
| <subsection name="Installing Hibernate Spatial"> |
| <p> |
| You will need to have the following libraries in your classpath: |
| hibernate, a JDBC driver and hibernate-spatial.jar, plus all transitive dependencies. |
| </p> |
| <p> |
| Geographic objects (or features) are characterized by having a geometry attribute: an attribute that |
| describes the |
| location and geometry of the object by means of a set of coordinates. Hibernate Spatial |
| uses the Geometry package of the |
| <a href="http://tsusiatsoftware.net/jts/main.html">Java Topology Suite</a> |
| to represent the geometries in Java. |
| </p> |
| </subsection> |
| <subsection name="Configuring a spatial dialect"> |
| <p> |
| If you want to use the geographic data support, you will need to configure Hibernate |
| with the appropriate Spatial Dialect. For example, to use the postgis spatial data support |
| in Postgresql, you need to add the following line in your hibernate.cfg.xml. |
| </p> |
| <source> |
| ... |
| <property name="hibernate.dialect">org.hibernate.spatial.dialect.postgis.PostgisDialect</property> |
| ... |
| </source> |
| <p> |
| The property value is here the class name of the dialect that extends the Hibernate Postgresql dialect |
| to include support |
| for spatial data. |
| </p> |
| </subsection> |
| <subsection name="Mapping Geometries"> |
| <p> |
| Geographic objects can now be represented in Java by means of POJO's that have a Geometry-valued |
| property. |
| Since we use the Java Topology Suite to represent geometries, this looks like: |
| </p> |
| <source> |
| import com.vividsolutions.jts.geom.Geometry; |
| ... |
| public Class SomeGeographicClass { |
| ... |
| private Geometry geometry; |
| ... |
| public Geometry getGeometry(){ |
| return this.geom; |
| } |
| public void setGeometry(Geometry geometry){ |
| this.geometry = geometry; |
| } |
| ... |
| } |
| </source> |
| <p> |
| The geometry property can be mapped by Hibernate by means of the special type |
| org.hibernatespatial.GeometryUserType, like this |
| </p> |
| <source> |
| ... |
| <property name="geometry" type="org.hibernate.spatial.GeometryType"> |
| <column name="geom" /> |
| </property> |
| ... |
| </source> |
| <p> |
| Working with geographic data (geometry-valued properties) is now exactly the same as working with any |
| other Hibernate-supported type. |
| </p> |
| </subsection> |
| </section> |
| <section name="Hibernate Spatial 1.x"> |
| <subsection name="Installing Hibernate Spatial"> |
| <p> |
| You will need to have the following libraries in your classpath: |
| hibernate (plus its dependencies), a JDBC driver for you database, |
| hibernate-spatial.jar and the appropriate spatial dialect provider for your database, and finally |
| the <a href="http://tsusiatsoftware.net/jts/main.html">Java Topology Suite</a> (jts.jar). |
| 28,8 → 103,8 |
| <a href="http://tsusiatsoftware.net/jts/main.html">Java Topology Suite</a> |
| to represent the geometries in Java. |
| </p> |
| </section> |
| <section name="Configuring a spatial dialect"> |
| </subsection> |
| <subsection name="Configuring a spatial dialect"> |
| <p> |
| If you want to use the geographic data support, you will need to configure Hibernate |
| with the appropriate Spatial Dialect. For example, to use the postgis spatial data support |
| 45,8 → 120,8 |
| to include support |
| for spatial data. |
| </p> |
| </section> |
| <section name="Mapping Geometries"> |
| </subsection> |
| <subsection name="Mapping Geometries"> |
| <p> |
| Geographic objects can now be represented in Java by means of POJO's that have a Geometry-valued |
| property. |
| 84,6 → 159,7 |
| Working with geographic data (geometry-valued properties) is now exactly the same as working with any |
| other Hibernate-supported type. |
| </p> |
| </subsection> |
| </section> |
| </body> |
| </document> |
| /trunk/hibernate-spatial/src/site/xdoc/download.xml |
|---|
| 40,6 → 40,140 |
| </section> |
| <section name="Releases"> |
| <subsection name="Release 4.00-M1"> |
| <p><strong>This release is compatible with Hibernate 4.x only.</strong></p> |
| <table> |
| <tr> |
| <th>Module</th> |
| <th>File</th> |
| <th>MD5 checksum</th> |
| </tr> |
| <tr> |
| <td>Hibernate Spatial (includes all dialects)</td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernate/hibernate-spatial/4.0-M1/hibernate-spatial-4.0-M1.jar"> |
| hibernate-spatial-4.0-M1.jar |
| </a> |
| </td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernate/hibernate-spatial/4.0-M1/hibernate-spatial-4.0-M1.jar.md5"> |
| hibernate-spatial-4.0-M1.jar.md5 |
| </a> |
| </td> |
| </tr> |
| </table> |
| </subsection> |
| <subsection name="Release 1.1.1"> |
| <table> |
| <tr> |
| <th>Module</th> |
| <th>File</th> |
| <th>MD5 checksum</th> |
| </tr> |
| <tr> |
| <td>Hibernate Spatial</td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial/1.1.1/hibernate-spatial-1.1.1.jar"> |
| hibernate-spatial-1.1.1.jar |
| </a> |
| </td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial/1.1.1/hibernate-spatial-1.1.1.jar.md5"> |
| hibernate-spatial-1.1.1.jar.md5 |
| </a> |
| </td> |
| </tr> |
| <tr> |
| <td>Oracle Spatial Provider</td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-oracle/1.1.1/hibernate-spatial-oracle-1.1.1.jar"> |
| hibernate-spatial-oracle-1.1.1.jar |
| </a> |
| </td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-oracle/1.1.1/hibernate-spatial-oracle-1.1.1.jar.md5"> |
| hibernate-spatial-oracle-1.1.1.jar.md5 |
| </a> |
| </td> |
| </tr> |
| <tr> |
| <td>Postgis provider</td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-postgis/1.1.1/hibernate-spatial-postgis-1.1.1.jar"> |
| hibernate-spatial-postgis-1.1.1.jar |
| </a> |
| </td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-postgis/1.1.1/hibernate-spatial-postgis-1.1.1.jar.md5"> |
| hibernate-spatial-postgis-1.1.1.jar.md5 |
| </a> |
| </td> |
| </tr> |
| <tr> |
| <td>Microsoft SQL Server provider</td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-sqlserver/1.1.1/hibernate-spatial-sqlserver-1.1.1.jar"> |
| hibernate-spatial-sqlserver-1.1.1.jar |
| </a> |
| </td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-sqlserver/1.1.1/hibernate-spatial-sqlserver-1.1.1.jar.md5"> |
| hibernate-spatial-sqlserver-1.1.1.jar.md5 |
| </a> |
| </td> |
| </tr> |
| <tr> |
| <td>MySQL Provider</td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-mysql/1.1.1/hibernate-spatial-mysql-1.1.1.jar"> |
| hibernate-spatial-mysql-1.1.1.jar |
| </a> |
| </td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-mysql/1.1.1/hibernate-spatial-mysql-1.1.1.jar.md5"> |
| hibernate-spatial-mysql-1.1.1.jar.md5 |
| </a> |
| </td> |
| </tr> |
| <tr> |
| <td>H2/GeoDB Provider</td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-h2-geodb/1.1.1/hibernate-spatial-h2-geodb-1.1.1.jar"> |
| hibernate-spatial-geodb-1.1.1.jar |
| </a> |
| </td> |
| <td> |
| <a |
| href="http://www.hibernatespatial.org/repository/org/hibernatespatial/hibernate-spatial-h2-geodb/1.1.1/hibernate-spatial-h2-geodb-1.1.1.jar.md5"> |
| hibernate-spatial-geodb-1.1.1.jar.md5 |
| </a> |
| </td> |
| </tr> |
| </table> |
| </subsection> |
| <subsection name="Release 1.1"> |
| 396,4 → 530,4 |
| </section> |
| </body> |
| </document> |
| </document> |
| /trunk/hibernate-spatial/src/site/xdoc/index.xml |
|---|
| 46,16 → 46,41 |
| NHibernate.Spatial</a>. |
| </p> |
| </section> |
| <section name="Compatibility with Hibernate"> |
| <section name="Compatibility with Hibernate ORM"> |
| <ul> |
| <li> |
| Hibernate Spatial version 1.0 is compatible with Hibernate 3.2.x - 3.5.x |
| </li> |
| <li> |
| Hibernate Spatial version 1.1 is compatible with Hibernate 3.6.x |
| Hibernate Spatial version 1.1.x is compatible with Hibernate 3.6.x |
| </li> |
| <li> |
| Hibernate Spatial version 4.0 is compatible with Hibernate 4.x |
| </li> |
| </ul> |
| </section> |
| <section name="Hibernate Spatial moving to Hibernate ORM"> |
| <p>We are currently working on migrating Hibernate Spatial to a module of the Hibernate ORM project. The move will |
| be complete by the time of the Hibernate 5 release.</p> |
| <p>The Hibernate Spatial Release 4 will be therefore be the last release that is made independently of Hibernate. |
| </p> |
| <p>We decided to base the release for Hibernate 4 on the new code for Hibernate 5 (hence the jump in version numberering). |
| This code is quite differently organised as the code for Hibernate spatial 1.x. The most visible differences are:</p> |
| <ul> |
| <li> |
| package <code>org.hibernatespatial</code> is now <code>org.hibernate.spatial</code> |
| </li> |
| <li> |
| only one jar needed: all dialects are now included in the base package |
| </li> |
| <li> |
| <code>GeometryUserType</code> is replaced by <code>GeometryType</code> |
| </li> |
| </ul> |
| <p>See the new <a href="/tutorial-hs4.html">tutorial for Hibernate Spatial 4</a> for more information.</p> |
| <p><strong>For Oracle users: custom <code>ConnectionFinder</code>s are not (yet) supported in version 4.0-M1.</strong> This will be fixed soon.</p> |
| </section> |
| <section name="Features"> |
| <p>Hibernate Spatial uses the Java Topology Suite (JTS) as its geometry model. JTS is an implementation of |
| the <a href="http://portal.opengeospatial.org/files/?artifact_id=829">OpenGIS Simple Features Implementation Specification for SQLv. 1.1 (SFS)</a>. |
| /trunk/hibernate-spatial/src/site/xdoc/release_notes.xml |
|---|
| 1,82 → 1,133 |
| <?xml version="1.0" encoding="UTF-8"?> |
| <document xmlns="http://maven.apache.org/XDOC/2.0" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> |
| <properties> |
| <title>Releases</title> |
| </properties> |
| <body> |
| <section name="Hibernate Spatial Releases"> |
| <subsection name="Release 1.1 (2010-05-20"> |
| <subsection name="Release 1.1.1 (2011-1-27)"> |
| <h4> Bug |
| </h4> |
| <ul> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-52'>HIBSPA-52</a>] - import oracle.jdbc.driver.OracleConnection; need to change to import oracle.jdbc.OracleConnection; |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-53'>HIBSPA-53</a>] - EventLocator doesn't properly copy SRID |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-55'>HIBSPA-55</a>] - Hibernate Spatial does not retrieve SRID on empty collections |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-56'>HIBSPA-56</a>] - Unit tests for MLineString fail |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-58'>HIBSPA-58</a>] - SQLServer DialectProvider does not check correct dialect |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-62'>HIBSPA-62</a>] - Schema information not taken into account by the automapper |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-63'>HIBSPA-63</a>] - Automapper creates invalid mapping when primary key is defined on multiple columns |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-65'>HIBSPA-65</a>] - AutoMapper throw NPE when a field type is not known |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-68'>HIBSPA-68</a>] - Couldn't get at the OracleSpatial Connection object from the PreparedStatement. |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-70'>HIBSPA-70</a>] - The 1.0 release is not compatible with Hibernate 3.6 |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-71'>HIBSPA-71</a>] - Trunk is not buildable |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-73'>HIBSPA-73</a>] - DefaultConnectionFinder can't find the original OracleConnection when using pools |
| </li> |
| </ul> |
| <h4>Bug |
| </h4> |
| <ul> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-83'>HIBSPA-83</a>] - Divide-by-zero |
| in getCoordinateAtM() method |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-84'>HIBSPA-84</a>] - |
| StackOverflowError during Circle.linearizeArc |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-86'>HIBSPA-86</a>] - |
| ClassCastException when saving geometries |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-87'>HIBSPA-87</a>] - Exception |
| using connection pool in Jboss 6.0 and Oracle 10g |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-91'>HIBSPA-91</a>] - Can't |
| convert object of type org.postgresql.util.PGobject - SpatialProjections.extent() |
| </li> |
| </ul> |
| <h4> Improvement |
| </h4> |
| <ul> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-57'>HIBSPA-57</a>] - Test tables should be empty after running unit tests |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-60'>HIBSPA-60</a>] - The Automapper should expose metadata about the geometry- and id properties |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-61'>HIBSPA-61</a>] - The AutoMapper should be able to handle cases where there are no primary keys defined on the table |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-69'>HIBSPA-69</a>] - PostGIS spatial indices |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-72'>HIBSPA-72</a>] - Move default dialect to conform to SQL/MM function name (Postgis 1.3 and later) |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-74'>HIBSPA-74</a>] - Make org.hibernatespatial.postgis.PostgisDialect Serializable |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-75'>HIBSPA-75</a>] - Remove Filter as a SpatialFunction |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-80'>HIBSPA-80</a>] - SQL Server provider should accept blob geometries |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-81'>HIBSPA-81</a>] - Change custom geometry types in SQL Server and Oracle provider dialects to protected static final to allow dialect extention |
| </li> |
| </ul> |
| </subsection> |
| <h4> New Feature |
| </h4> |
| <ul> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-6'>HIBSPA-6</a>] - New MySQLInnoDBSpatialDialect needed |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-13'>HIBSPA-13</a>] - Create H2 spatial dialect |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-49'>HIBSPA-49</a>] - Add Common methods to SpatialRestrictions/HQL |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-66'>HIBSPA-66</a>] - Dialects should report which spatial functions they support |
| </li> |
| </ul> |
| <subsection name="Release 1.1 (2011-05-20"> |
| <h4>Bug |
| </h4> |
| <ul> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-52'>HIBSPA-52</a>] - import |
| oracle.jdbc.driver.OracleConnection; need to change to import oracle.jdbc.OracleConnection; |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-53'>HIBSPA-53</a>] - EventLocator |
| doesn't properly copy SRID |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-55'>HIBSPA-55</a>] - Hibernate |
| Spatial does not retrieve SRID on empty collections |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-56'>HIBSPA-56</a>] - Unit tests for |
| MLineString fail |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-58'>HIBSPA-58</a>] - SQLServer |
| DialectProvider does not check correct dialect |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-62'>HIBSPA-62</a>] - Schema |
| information not taken into account by the automapper |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-63'>HIBSPA-63</a>] - Automapper |
| creates invalid mapping when primary key is defined on multiple columns |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-65'>HIBSPA-65</a>] - AutoMapper |
| throw NPE when a field type is not known |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-68'>HIBSPA-68</a>] - Couldn't |
| get at the OracleSpatial Connection object from the PreparedStatement. |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-70'>HIBSPA-70</a>] - The 1.0 |
| release is not compatible with Hibernate 3.6 |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-71'>HIBSPA-71</a>] - Trunk is not |
| buildable |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-73'>HIBSPA-73</a>] - |
| DefaultConnectionFinder can't find the original OracleConnection when using pools |
| </li> |
| </ul> |
| <h4>Improvement |
| </h4> |
| <ul> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-57'>HIBSPA-57</a>] - Test tables |
| should be empty after running unit tests |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-60'>HIBSPA-60</a>] - The Automapper |
| should expose metadata about the geometry- and id properties |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-61'>HIBSPA-61</a>] - The AutoMapper |
| should be able to handle cases where there are no primary keys defined on the table |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-69'>HIBSPA-69</a>] - PostGIS |
| spatial indices |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-72'>HIBSPA-72</a>] - Move default |
| dialect to conform to SQL/MM function name (Postgis 1.3 and later) |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-74'>HIBSPA-74</a>] - Make |
| org.hibernatespatial.postgis.PostgisDialect Serializable |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-75'>HIBSPA-75</a>] - Remove Filter |
| as a SpatialFunction |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-80'>HIBSPA-80</a>] - SQL Server |
| provider should accept blob geometries |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-81'>HIBSPA-81</a>] - Change custom |
| geometry types in SQL Server and Oracle provider dialects to protected static final to allow |
| dialect extention |
| </li> |
| </ul> |
| <h4>New Feature |
| </h4> |
| <ul> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-6'>HIBSPA-6</a>] - New |
| MySQLInnoDBSpatialDialect needed |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-13'>HIBSPA-13</a>] - Create H2 |
| spatial dialect |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-49'>HIBSPA-49</a>] - Add Common |
| methods to SpatialRestrictions/HQL |
| </li> |
| <li>[<a href='http://www.hibernatespatial.org/jira/browse/HIBSPA-66'>HIBSPA-66</a>] - Dialects |
| should report which spatial functions they support |
| </li> |
| </ul> |
| </subsection> |
| <subsection name="Release 1.0 (2010-04-05)"> |
| 181,8 → 232,8 |
| </li> |
| </ul> |
| </subsection> |
| </section> |
| </body> |
| </document> |
| </section> |
| </body> |
| </document> |
| /trunk/hibernate-spatial/src/site/xdoc/gettinghelp.xml |
|---|
| 18,8 → 18,8 |
| </p> |
| <p> |
| The mailing list is archived on Nabble (<a |
| href="http://n2.nabble.com/Hibernate-Spatial-Users-f1140994.html">goto forum</a>). The archive is |
| read-only, so posting messages there won't work. |
| href="http://hibernate-spatial.1140993.n2.nabble.com/">goto forum</a>). <strong>The archive is |
| read-only, so posting messages there won't work.</strong> |
| </p> |
| <p>To submit bug reports, request new features, or suggest improvements you should use <a |
| href="http://www.hibernatespatial.org/jira/browse/HIBSPA">the issue management system</a>. |
| /trunk/hibernate-spatial/src/site/xdoc/providers.xml |
|---|
| 30,7 → 30,7 |
| xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> |
| <body> |
| <section name="Spatial Dialect Providers"> |
| <section name="Spatial Dialect Providers (Hibernate Spatial 1.x only!)"> |
| <p> |
| Hibernate Spatial requires Spatial Dialect Providers to supply the database specific support for |
| geographic data. |
| /trunk/hibernate-spatial/src/site/xdoc/tutorial-hs4.xml |
|---|
| New file |
| 0,0 → 1,683 |
| <?xml version="1.0" encoding="UTF-8"?> |
| <document xmlns="http://maven.apache.org/XDOC/2.0" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> |
| <properties> |
| <title>Tutorial</title> |
| <author>Karel Maesen</author> |
| </properties> |
| <body> |
| <section name="Introduction"> |
| <p> |
| This tutorial gives a quick overview of how to get |
| Hibernate Spatial 4.x working. We will develop a simple |
| application that stores, and retrieves some |
| simple data objects. The data objects are "special" in |
| that they have a property of type Geometry. |
| </p> |
| <p> |
| This tutorial assumes |
| that you are familiar with Hibernate and the basic |
| concepts of working with geographic data. |
| </p> |
| <p> |
| For this tutorial We require a postgis database. For information on how to create a postgis database, you should consult |
| <a href="http://postgis.refractions.net/documentation/manual-1.5/">the postgis documentation</a>. For this tutorial we used Postgresql 8.4 and |
| Postgis 1.5. |
| </p> |
| </section> |
| <section name="Creating a Spatially-Enabled EventManager"> |
| <p> |
| We will create a small application to store and retrieve events we want to attend. (This is |
| the same use case as in the Hibernate Tutorial). |
| </p> |
| <subsection name="Setup"> |
| <p> |
| We first need to set up our development environment. We will use the |
| <a href="http://maven.org/">Maven</a> |
| build tool in this tutorial. |
| </p> |
| <p>Maven can generate the basic structure of our simple application using the<code>mvn |
| archetype:generate</code>. |
| For this example, we specify type (the default) and set |
| <code>groupId</code> |
| to <code>org.hibernate.spatial.tutorials</code>, |
| <code>artifactId</code> |
| to |
| <code>event-tutorial</code> |
| and |
| <code>package</code> |
| to <code>event</code>. |
| </p> |
| <source> |
| mvn archetype:generate |
| [INFO] Scanning for projects... |
| [INFO] Searching repository for plugin with prefix: 'archetype'. |
| [INFO] ------------------------------------------------------------------------ |
| [INFO] Building Maven Default Project |
| [INFO] task-segment: [archetype:generate] (aggregator-style) |
| [INFO] ------------------------------------------------------------------------ |
| [INFO] Preparing archetype:generate |
| [INFO] No goals needed for project - skipping |
| [INFO] Setting property: classpath.resource.loader.class => |
| 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. |
| ....... |
| Define value for groupId: : org.hibernate.spatial.tutorials |
| Define value for artifactId: : event-tutorial |
| Define value for version: 1.0-SNAPSHOT: : |
| Define value for package: : event |
| Confirm properties configuration: |
| groupId: org.hibernatespatial.tutorials |
| artifactId: event-tutorial |
| version: 1.0-SNAPSHOT |
| package: event |
| Y: : Y |
| ...... |
| [INFO] ------------------------------------------------------------------------ |
| [INFO] BUILD SUCCESSFUL |
| [INFO] ------------------------------------------------------------------------ |
| [INFO] Total time: 36 seconds |
| [INFO] Finished at: Mon Apr 05 17:23:22 CEST 2010 |
| [INFO] Final Memory: 15M/158M |
| [INFO] ------------------------------------------------------------------------ |
| </source> |
| <p>This results in the following directory structure.</p> |
| <source> |
| <![CDATA[ |
| . |
| |-- pom.xml |
| `-- src |
| |-- main |
| | |-- java |
| | | |-- event |
| | | `-- App.java |
| `-- test |
| `-- java |
| `-- event |
| ]]> |
| </source> |
| <p>We now need to edit the pom to add the required dependencies and repositories (see also the <a |
| href="mavenquick.html">Maven Quick Start</a>.). |
| </p> |
| <source> |
| <![CDATA[ |
| <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/xsd/maven-4.0.0.xsd"> |
| <modelVersion>4.0.0</modelVersion> |
| <groupId>org.hibernate.spatial.tutorials</groupId> |
| <artifactId>event-tutorial</artifactId> |
| <version>1.0-SNAPSHOT</version> |
| <packaging>jar</packaging> |
| <name>event-tutorial</name> |
| <url>http://maven.apache.org</url> |
| <properties> |
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| <hibernate.version>4.0.0.Final</hibernate.version> |
| </properties> |
| <build> |
| <finalName>${artifactId}</finalName> |
| <plugins> |
| <plugin> |
| <artifactId>maven-compiler-plugin</artifactId> |
| <configuration> |
| <source>1.6</source> |
| <target>1.6</target> |
| <encoding>UTF-8</encoding> |
| </configuration> |
| </plugin> |
| </plugins> |
| </build> |
| <dependencies> |
| <!-- Hibernate Spatial --> |
| <dependency> |
| <groupId>org.hibernate</groupId> |
| <artifactId>hibernate-spatial</artifactId> |
| <version>4.0-M1</version> |
| </dependency> |
| <dependency> |
| <groupId>org.hibernate</groupId> |
| <artifactId>hibernate-entitymanager</artifactId> |
| <version>${hibernate.version}</version> |
| </dependency> |
| <!-- the postgresql driver --> |
| <dependency> |
| <groupId>postgresql</groupId> |
| <artifactId>postgresql</artifactId> |
| <version>8.4-701.jdbc3</version> |
| </dependency> |
| <dependency> |
| <groupId>org.slf4j</groupId> |
| <artifactId>slf4j-log4j12</artifactId> |
| <version>1.5.11</version> |
| </dependency> |
| </dependencies> |
| <!-- add repositories for JTS and Hibernate Spatial and Hibernate (JBoss) --> |
| <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> |
| <!-- add JBOSS repository for easy access to Hibernate libraries --> |
| <repository> |
| <id>JBOSS</id> |
| <url>https://repository.jboss.org/nexus/content/repositories/releases/</url> |
| </repository> |
| </repositories> |
| </project> |
| ]]> |
| </source> |
| <p>With the command |
| <code>mvn dependency:list</code> |
| we can see which libraries are required for our minimal |
| Hibernate Spatial application. |
| </p> |
| <source> |
| $ mvn dependency:list |
| .... |
| [INFO] The following files have been resolved: |
| [INFO] antlr:antlr:jar:2.7.7:compile |
| [INFO] com.fasterxml:classmate:jar:0.5.4:compile |
| [INFO] com.vividsolutions:jts:jar:1.12:compile |
| [INFO] commons-collections:commons-collections:jar:3.2.1:compile |
| [INFO] dom4j:dom4j:jar:1.6.1:compile |
| [INFO] javassist:javassist:jar:3.12.1.GA:compile |
| [INFO] log4j:log4j:jar:1.2.14:compile |
| [INFO] org.hibernate:hibernate-core:jar:4.0.0.Final:compile |
| [INFO] org.hibernate:hibernate-entitymanager:jar:4.0.0.Final:compile |
| [INFO] org.hibernate:hibernate-spatial:jar:4.0-M1:compile |
| [INFO] org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile |
| [INFO] org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile |
| [INFO] org.jboss:jandex:jar:1.0.3.Final:compile |
| [INFO] org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile |
| [INFO] org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile |
| [INFO] org.postgis:postgis-jdbc:jar:1.5.3:compile |
| [INFO] org.slf4j:slf4j-api:jar:1.5.11:compile |
| [INFO] org.slf4j:slf4j-log4j12:jar:1.5.11:compile |
| [INFO] postgresql:postgresql:jar:8.4-701.jdbc3:compile |
| [INFO] xerces:xercesImpl:jar:2.4.0:compile |
| [INFO] xml-apis:xml-apis:jar:1.0.b2:compile |
| </source> |
| <p>Hibernate Spatial works with a wide range of versions of these libraries, so don't be too concerned |
| if you see |
| either more recent or slightly older versions. |
| </p> |
| </subsection> |
| <subsection name="The Event Class"> |
| <p>Our persistent class is the |
| <code>Event</code> |
| class. Since this class |
| contains a geometry-valued property (a property of type Geometry), its instances |
| are geographic objects, or features. |
| </p> |
| <source> |
| <![CDATA[ |
| package event; |
| import com.vividsolutions.jts.geom.Point; |
| import org.hibernate.annotations.GenericGenerator; |
| import org.hibernate.annotations.Type; |
| import javax.persistence.*; |
| import java.util.Date; |
| /** |
| * @author Karel Maesen, Geovise BVBA |
| * creation-date: 6/18/12 |
| */ |
| @Entity |
| public class Event { |
| @Id |
| @GeneratedValue(generator="increment") |
| @GenericGenerator(name="increment", strategy = "increment") |
| private Long id; |
| private String title; |
| private Date date; |
| @Type(type="org.hibernate.spatial.GeometryType") |
| private Point location; |
| public Event() { |
| } |
| public Long getId() { |
| return id; |
| } |
| private void setId(Long id) { |
| this.id = id; |
| } |
| public Date getDate() { |
| return date; |
| } |
| public void setDate(Date date) { |
| this.date = date; |
| } |
| public String getTitle() { |
| return title; |
| } |
| public void setTitle(String title) { |
| this.title = title; |
| } |
| public Point getLocation() { |
| return this.location; |
| } |
| public void setLocation(Point location) { |
| this.location = location; |
| } |
| } |
| ]]> |
| </source> |
| <p>We put this file in the |
| <code>./src/main/java/event</code> |
| directory of the development directory. |
| </p> |
| <p>Note the @Type annotation. This informs Hibernate that the location attribute is of type Geometry. |
| The @Type annotation is Hibernate specific, and the only non-JPA annotation that is required. |
| In future versions of Hibernate (version 5 and later) it will no longer be necessary to explicitly |
| declare the Type of Geometry-valued attributes. |
| this </p> |
| </subsection> |
| <subsection name="The Hibernate/JPA Configuration"> |
| <p> |
| We proceed with the hibernate configuration file. The only difference |
| w.r.t. the usual Hibernate/JPA configurations is the dialect |
| property. Hibernate Spatial extends the Hibernate <code>Dialect</code>s so that the spatial |
| functions of the database are available within HQL and JPQL. So instead of using |
| the (in our case) PostgreSQLDialect, we use Hibernate Spatial's |
| extension of that dialect which is the PostGISDialect. |
| Our |
| <code>persistence.xml</code> |
| looks like this: |
| <source> |
| <![CDATA[ |
| <persistence xmlns="http://java.sun.com/xml/ns/persistence" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" |
| version="2.0"> |
| <persistence-unit name="org.hibernate.events.jpa" transaction-type="RESOURCE_LOCAL"> |
| <properties> |
| <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/> |
| <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/> |
| <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432:hstutorial"/> |
| <property name="hibernate.connection.username" value="hstutorial"/> |
| <property name="hibernate.connection.password" value="hstutorial"/> |
| <property name="hibernate.connection.pool_size" value="5"/> |
| <property name="hibernate.show_sql" value="true"/> |
| <property name="hibernate.format_sql" value="true"/> |
| <property name="hibernate.max_fetch_depth" value="5"/> |
| <property name="hibernate.hbm2ddl.auto" value="update"/> |
| </properties> |
| </persistence-unit> |
| </persistence> |
| ]]> |
| </source> |
| As is usual when building with maven, we store this file in the |
| <code>./src/main/resources/META-INF</code> |
| directory. |
| </p> |
| <p> |
| Note that this configuration file means that Hibernate will connect to the "events" |
| database on localhost, with username "hstutorial" and password "hstutorial". |
| You may need to change these values to reflect your set-up. |
| </p> |
| <p> |
| Also notice that the "hbm2dll.auto" property is set to 'update'. This will create the |
| necessary table(s) when the application is run for the first time. |
| </p> |
| </subsection> |
| </section> |
| <section name="The JPAUtil helper"> |
| <p> |
| The |
| <code>JPAUtil</code> |
| class creates the <code>EntityManagerFactory</code> for the application, and provides a method |
| to create <code>EntityManager</code> instances. |
| </p> |
| <source> |
| <![CDATA[ |
| package util; |
| import javax.persistence.EntityManager; |
| import javax.persistence.EntityManagerFactory; |
| import javax.persistence.Persistence; |
| public class JPAUtil { |
| private static final EntityManagerFactory emFactory; |
| static { |
| try { |
| emFactory = Persistence.createEntityManagerFactory("org.hibernate.events.jpa"); |
| }catch(Throwable ex){ |
| System.err.println("Cannot create EntityManagerFactory."); |
| throw new ExceptionInInitializerError(ex); |
| } |
| } |
| public static EntityManager createEntityManager() { |
| return emFactory.createEntityManager(); |
| } |
| public static void close(){ |
| emFactory.close(); |
| } |
| } |
| ]]> |
| </source> |
| </section> |
| <section name="The EventManager"> |
| <p> |
| We are now ready to write a first version of the main application class<code>EventManager</code>. |
| </p> |
| <source> |
| <![CDATA[ |
| package event; |
| import com.vividsolutions.jts.geom.Geometry; |
| import com.vividsolutions.jts.geom.Point; |
| import com.vividsolutions.jts.io.ParseException; |
| import com.vividsolutions.jts.io.WKTReader; |
| import util.JPAUtil; |
| import javax.persistence.EntityManager; |
| import javax.persistence.Query; |
| import java.util.Date; |
| import java.util.List; |
| /** |
| * @author Karel Maesen, Geovise BVBA |
| * creation-date: 6/19/12 |
| */ |
| public class EventManager { |
| public static void main(String[] args) { |
| EventManager mgr = new EventManager(); |
| if (args[0].equals("store")) { |
| mgr.createAndStoreEvent("My Event", new Date(), assemble(args)); |
| } |
| JPAUtil.close(); |
| } |
| private void createAndStoreEvent(String title, Date theDate, String wktPoint) { |
| Geometry geom = wktToGeometry(wktPoint); |
| if (!geom.getGeometryType().equals("Point")) { |
| throw new RuntimeException("Geometry must be a point. Got a " + geom.getGeometryType()); |
| } |
| EntityManager em = JPAUtil.createEntityManager(); |
| em.getTransaction().begin(); |
| Event theEvent = new Event(); |
| theEvent.setTitle(title); |
| theEvent.setDate(theDate); |
| theEvent.setLocation((Point) geom); |
| em.persist(theEvent); |
| em.getTransaction().commit(); |
| em.close(); |
| } |
| private Geometry wktToGeometry(String wktPoint) { |
| WKTReader fromText = new WKTReader(); |
| Geometry geom = null; |
| try { |
| geom = fromText.read(wktPoint); |
| } catch (ParseException e) { |
| throw new RuntimeException("Not a WKT string:" + wktPoint); |
| } |
| return geom; |
| } |
| /** |
| * Utility method to assemble all arguments save the first into a String |
| */ |
| private static String assemble(String[] args) { |
| StringBuilder builder = new StringBuilder(); |
| for (int i = 1; i < args.length; i++) { |
| builder.append(args[i]).append(" "); |
| } |
| return builder.toString(); |
| } |
| } |
| ]]> |
| </source> |
| <p> |
| The |
| <code>EventManger</code> |
| stores a point that represents the location for the event. The point is given as a String in the Well-Known Text (WKT) format. See |
| <a href="http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/io/WKTReader.html">the JTS |
| WTKReader JavaDoc</a> for more information about the WTK format. |
| (The <code>assemble()</code> method is necessary because the Maven exec plugin |
| parses string with spaces as a list of command-line arguments.) |
| </p> |
| <p> |
| The development directory now looks like this. |
| <source> |
| <![CDATA[ |
| . |
| |-- pom.xml |
| `-- src |
| |-- main |
| | |-- java |
| | | |-- event |
| | | | |-- Event.java |
| | | | `-- EventManager.java |
| | | `-- util |
| | | `-- JPAUtil.java |
| | `-- resources |
| | `-- META-INF |
| | `-- persistence.xml |
| | |
| `-- test |
| `-- java |
| `-- event |
| ]]> |
| </source> |
| </p> |
| <p> |
| We can now build this program using maven: |
| <source> |
| <![CDATA[ $ mvn compile ]]> |
| </source> |
| We can now execute the program using maven as follows: |
| <source> |
| <![CDATA[ mvn exec:java -Dexec.mainClass="event.EventManager" -Dexec.args="store POINT(10 5)"]]> |
| </source> |
| </p> |
| <p> |
| This will create the events table, add a new event with the date set to today, the title to "My Title", |
| and the point to coordinates (10,15). |
| </p> |
| <p> |
| We can check the content of the events table using the astext() function that |
| converts the geometries to their WKT representation. |
| </p> |
| <source> |
| <![CDATA[ events=# select title, astext(location) from events; |
| title | astext |
| ----------+-------------- |
| My Event | POINT(10 15) |
| (1 row) ]]> |
| </source> |
| </section> |
| <section name="Spatial Queries"> |
| <p>We will now modify the |
| <code>EventManager</code> |
| by adding an action to list all events within a certain area. |
| This will show how to use Hibernate Spatial for spatial querying. |
| </p> |
| <p> |
| Here is the addition to the |
| <code>main</code> |
| method in the |
| <code>EventManager</code> |
| that |
| implements the "find" action. |
| <source> |
| <![CDATA[ |
| ... |
| if (args[0].equals("store")) { |
| mgr.createAndStoreEvent("My Event", new Date(), assemble(args)); |
| } else if (args[0].equals("find")) { |
| List events = mgr.find(args[1]); |
| for (int i = 0; i < events.size(); i++) { |
| Event event = (Event) events.get(i); |
| System.out.println("Event: " + event.getTitle() + |
| ", Time: " + event.getDate() + |
| ", Location: " + event.getLocation()); |
| } |
| } |
| ... |
| ]]> |
| </source> |
| We also need to implement the |
| <code>find(String filter)</code> |
| method. |
| </p> |
| <p> |
| The |
| <code>find</code> |
| method takes a WKT string that represents a polygon, and |
| searches the events table for all events that are located within this polygon. |
| </p> |
| <p> |
| Here is the code. |
| <source> |
| <![CDATA[ |
| ... |
| private List find(String wktFilter) { |
| Geometry filter = wktToGeometry(wktFilter); |
| EntityManager em = JPAUtil.createEntityManager(); |
| em.getTransaction().begin(); |
| Query query = em.createQuery("select e from Event e where st_within(e.location, :filter) = true", Event.class); |
| query.setParameter("filter", filter); |
| return query.getResultList(); |
| } |
| ... |
| ]]> |
| </source> |
| </p> |
| <p> |
| The |
| <code>st_within</code> function is registered in the Dialect <code>PostgisDialect</code> |
| method. It takes two parameters: the first is the name of the Geometry-valued property on which the filter |
| is applied; the second is the filter geometry. |
| </p> |
| <p> |
| If now run: |
| <source> |
| <![CDATA[ $ mvn exec:java -Dexec.mainClass="event.EventManager" -Dexec.args="find POLYGON((1\ 1,20\ 1,20\20,1\ 20,1\ 1))" ]]> |
| </source> |
| We get |
| <source> |
| <![CDATA[ |
| ... |
| Hibernate: |
| select |
| event0_.id as id0_, |
| event0_.date as date0_, |
| event0_.location as location0_, |
| event0_.title as title0_ |
| from |
| Event event0_ |
| where |
| st_within(event0_.location, ?)=true |
| Event: My Event, Time: 2012-06-19 15:20:06.049, Location: POINT (10 5) |
| ... |
| ]]> |
| </source> |
| The first lines show the SQL generated by Hibernate (with a little help of Hibernate Spatial). |
| It is shown because the |
| <code>show_sql</code> |
| property is set in the configuration file. |
| The last line is the output generated by the |
| <code>find</code> |
| action. |
| </p> |
| </section> |
| <section name="But I use Oracle/MySQL/SQLServer/... so what do I do?"> |
| <p>If you need to run Hibernate Spatial on a different database, you need to change the JDBC driver (obviously) and |
| set the appropriate spatial dialect. Currently, your choices are: |
| </p> |
| <ol> |
| <li>Oracle 10g/11g: <code>org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect</code></li> |
| <li>MySQL 5+: <code>org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect</code> or <code> org.hibernate.spatial.dialect.mysql.MySQLSpatialInnoDBDialect</code></li> |
| <li>Microsoft SQL Server 2008 : <code>org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect</code></li> |
| <li>H2 + GeoDB: <code>org.hibernate.spatial.dialect.h2geodb.GeoDBDialect</code></li> |
| </ol> |
| </section> |
| </body> |
| </document> |
| /trunk/hibernate-spatial/pom.xml |
|---|
| 1,3 → 1,4 |
| <?xml version="1.0" encoding="UTF-8"?> |
| <project> |
| <modelVersion>4.0.0</modelVersion> |
| 6,7 → 7,7 |
| <parent> |
| <groupId>org.hibernatespatial</groupId> |
| <artifactId>hibernate-spatial-maven</artifactId> |
| <version>1.1.1-SNAPSHOT</version> |
| <version>4.0-M1</version> |
| <relativePath>../hibernate-spatial-maven</relativePath> |
| </parent> |
| <name>Hibernate Spatial Core</name> |
| 46,6 → 47,18 |
| </plugins> |
| </build> |
| <scm> |
| <connection> |
| scm:git:git://github.com/maesenka/hibernate-core.git |
| </connection> |
| <developerConnection> |
| scm:git:git@github.com:maesenka/hibernate-core.git |
| </developerConnection> |
| <url> |
| <![CDATA[ https://github.com/maesenka/hibernate-core]]> |
| </url> |
| </scm> |
| <distributionManagement> |
| <site> |
| <id>Hibernate Spatial site</id> |