PostGIS + JPA + Hibernate - Centroid Query
Hello fellow overflowers! I was hoping I could get some help with this query.  I am still rather new to hibernate and JPA and do not quite understand how to do custom queries.  I can query for whole objects but cannot figure out how to get what I want with this one.  I am using an entityManager instead of sessionfactory also.  Here's what I got so far:

    public String findCentroid(final DTOobject objectIn)
       {
          final Query query = entityManager.createQuery("select ST_Centroid(geometry) from DTOobject object where id = :id ");
          query.setParameter("id", objectIn.getId());
    
          List temp = query.getResultList();
    
          return (String) temp.get(0);
       }

I abstracted my actual object for DTOobject but all you need to know is that it has a geometry field in the database.  But essentially I am calling the postgis function ST_Centroid and do not know how to get the results of this database call.  This same query from the postgres command prompt works fine, I just can't get the results back to Java. What am I missing here? I feel like this should be easy.
PostGIS + JPA + Hibernate - Centroid Query
===

Hello fellow overflowers! I was hoping I could get some help with this query.  I am still rather new to hibernate and JPA and do not quite understand how to do custom queries.  I can query for whole objects but cannot figure out how to get what I want with this one.  I am using an entityManager instead of sessionfactory also.  Here's what I got so far:

    public String findCentroid(final DTOobject objectIn)
       {
          final Query query = entityManager.createQuery("select ST_Centroid(geometry) from DTOobject object where id = :id ");
          query.setParameter("id", objectIn.getId());
    
          List temp = query.getResultList();
    
          return (String) temp.get(0);
       }

I abstracted my actual object for DTOobject but all you need to know is that it has a geometry field in the database.  But essentially I am calling the postgis function ST_Centroid and do not know how to get the results of this database call.  This same query from the postgres command prompt works fine, I just can't get the results back to Java. What am I missing here? I feel like this should be easy.