How to correctly map a polygon type with postgis and hibernate-spatial?
<p>Assume I have the following table</p>

<pre><code>CREATE TABLE foo (
  id BIGSERIAL PRIMARY KEY, 
  polygon GEOMETRY(POLYGON)
);
</code></pre>

<p>and entity class</p>

<pre><code>@Table
@Entity
public class Foo {

   @Id
   @GeneratedValue(strategy = IDENTITY)
   private Long id;

   private Polygon polygon;

}
</code></pre>

<p>I managed to save a Foo entity, however, I can't select it them from the database. I get this exception:</p>

<pre><code>java.lang.NumberFormatException: For input string: "PO"
</code></pre>

<p>Then, I added the following annotation on top of polygon field:</p>

<pre><code>@Type(type = "org.hibernate.spatial.JTSGeometryType")
</code></pre>

<p>but it throws
 another exception saying that this type cannot be instantiated:</p>

<pre><code>org.hibernate.MappingException: Could not instantiate Type: org.hibernate.spatial.JTSGeometryType
</code></pre>

<p>Please note that I use 5.1.0.Final version for hibernate and hibernate-spatial.</p>

<p>Thank you</p>