title: How can I get a String from this Geometry Object with hibernate and PostGIS
body: <p>I would like to return the output (Output is "0101000020E610000000000000000024400000000000002440" in geometry type) of this SQL Postgis query</p>
  
  <pre><code>select ST_GeometryFromText('POINT(10 10)',4326)
  </code></pre>
  
  <p>in Java with hibernate.</p>
  
  <p>I tried it with the following method: </p>
  
  <pre><code>public String computeGeomFromLongitudeLatitude() {
      Session session = getSession();
      String geom = (String) session
              .createSQLQuery(
                      "select ST_GeometryFromText('POINT(10 10)',4326)").list().get(0);
      closeSession();
  
      return geom;
  }
  </code></pre>
  
  <p>This doesn't work for me. I get the following exception</p>
  
  <pre><code>Exception in thread "main" org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111
      at org.hibernate.dialect.TypeNames.get(TypeNames.java:76)
      at org.hibernate.dialect.TypeNames.get(TypeNames.java:99)
      at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:563)
      at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:660)
      at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:564)
      at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:580)
      at org.hibernate.loader.Loader.getResultSet(Loader.java:1986)
      at org.hibernate.loader.Loader.doQuery(Loader.java:829)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
      at org.hibernate.loader.Loader.doList(Loader.java:2463)
      at org.hibernate.loader.Loader.doList(Loader.java:2449)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2279)
      at org.hibernate.loader.Loader.list(Loader.java:2274)
      at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:331)
      at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1585)
      at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:224)
      at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:156)
      at database.BerlinPolygonDAO.computeGeomFromLongitudeLatitude(BerlinPolygonDAO.java:305)
      at database.BerlinPolygonDAO.main(BerlinPolygonDAO.java:330)
  </code></pre>
  
  <p>I think I understand what the problem is. I try to parse the result as a String but it's a Geometry object. But what can I do to get this output as String in Java? I already get an exception if I only add .list() behind the SQL query. </p>
  
  <p>Thanks a lot for your ideas. </p>
  
  <p>EDIT: </p>
  
  <p>I have the correct Dialog specified in my hibernate.cfg</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;property name="hibernate.connection.driver_class"&gt;org.postgresql.Driver&lt;/property&gt;
          &lt;property name="hibernate.connection.url"&gt;jdbc:postgresql://localhost:5432/GIS&lt;/property&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;postgres&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;mysql15&lt;/property&gt;
          &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
          &lt;property name="hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;
          &lt;property name="hibernate.show_sql"&gt;false&lt;/property&gt;
  
          &lt;mapping class="database.tables.flickr.User" /&gt;
          &lt;mapping class="database.tables.flickr.Photo" /&gt;
          &lt;mapping class="database.tables.flickr.Tag" /&gt;
          &lt;mapping class="database.tables.OwnPolygon" /&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>