title: Hibernate executeUpdate() on PostgreSQL function
body: <p>I am using hibernate with a function in PostgreSQL to update a record in the DB.</p>
  
  <p>Following is the PostgreSQL function,</p>
  
  <pre><code>    CREATE OR REPLACE FUNCTION updatesegment(segid bigint, segname text, segdesc text, segmeta text)
        RETURNS void AS
      $BODY$
        BEGIN
          UPDATE segment
          SET
             name = segname,
             description = segdesc,
             segmentmetadata = segmeta
          WHERE
             id = segid;
        END;
      $BODY$
      LANGUAGE plpgsql;
  </code></pre>
  
  <p>In the java code I am invoking the function as below.</p>
  
  <pre><code>public int updateSegment(Long segmentId, String segName, String segDesc, String segMeta) {
  
      SQLQuery query = (SQLQuery)sessionFactory.getCurrentSession().createSQLQuery("SELECT updatesegment(:segmentId, :segName, :segDesc, :segMeta)")
              .setParameter("segmentId", segmentId)
              .setParameter("segName", segName)
              .setParameter("segDesc", segDesc)
              .setParameter("segMeta", segMeta);
  
      int rows = query.executeUpdate();
  
      return rows;
  }
  </code></pre>
  
  <p>When I call the updateSegment() java function above with the correct input parameters, the record in the DB gets updated as expected. But query.executeUpdate() is always returning 0 where as it should be returning 1.</p>
  
  <p>What am I doing wrong and why isn't executeUpdate() returning 1?</p>
  
  <p>Thanks in advance...!!! </p>