I work with hibernate-spatial 5.2.10 and postgis, and I'm trying to persist Point datatype to DB table which consist of two columns:
- name = uid, type = bigint (primary key, not null)
- name = center, type = point
Here is my code:
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import org.hibernate.Session;
... 
public class TestGIS {
  @Test
  public void testSavePosition() {
    StandardServiceRegistry standardRegistry =
        new StandardServiceRegistryBuilder().configure("hibernate.gis-test.cfg.xml").build();
    Metadata metadata =
    new MetadataSources(standardRegistry).addAnnotatedClass(Position.class)
                                         .getMetadataBuilder()
                                         .build();
    SessionFactory sessionFactory = metadata.getSessionFactoryBuilder().build();
    Session session = sessionFactory.openSession();
    session.beginTransaction();
    GeometryFactory factory = new GeometryFactory();
    Position position = new Position(1, factory.createPoint(new Coordinate(10.0, 20.0)));
    session.persist(position);
    session.flush();
    session.close();
    sessionFactory.close();
  }
  @Entity
  @Table(name = "positions")
  public static class Position {
    @Id
    @Column
    private long uid;
    @Column
    private Point center;
    public Position(long uid, Point center) {
      this.uid = uid;
      this.center = center;
    }
    public Position() {
    }
    // getters and setters
  }
}
and here is the configuration code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <!-- a SessionFactory instance listed as /jndi/name -->
  <session-factory
      name="java:hibernate/SessionFactory">
    <!-- properties -->
    <property name="connection.driver_class">org.postgresql.Driver</property>
    <property name="dialect">org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect</property>
    <property name="show_sql">true</property>
    <property name="connection.url">jdbc:postgresql://127.0.0.1:2345/gis_sandbox</property>
    <property name="connection.username">****</property>
    <property name="connection.password">****</property>
    <property name="jta.UserTransaction">java:comp/UserTransaction</property>
  </session-factory>
</hibernate-configuration>
When I run the code above I get this massege:
ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ERROR: column "center" is of type point but expression is of type bytea
How should I insert Point datatype into this table?
