Note that there are some explanatory texts on larger screens.

plurals
  1. POOracle stored procedures, SYS_REFCURSOR and NHibernate
    primarykey
    data
    text
    <p>I have a legacy Oracle (10.2g) database that I'm connecting to and I'd like to use NHibernate (2.0.1) to give me back objects from a stored procedure. The stored procedure in question uses a SYS_REFCURSOR to return results. According to the <a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/querysql.html#querysql-limits-storedprocedures" rel="noreferrer">documentation</a> this should be doable but I've found a <a href="http://forum.hibernate.org/viewtopic.php?p=2398761" rel="noreferrer">few</a> <a href="http://groups.google.com/group/nhusers/browse_thread/thread/1e5c71502dd547f0/a7908ea36bed6a5e" rel="noreferrer">posts</a> on the internet that suggest otherwise.</p> <p>Here's my paraphrased code:</p> <p>Mapping file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="OracleStoredProcedures" namespace="OracleStoredProcedures"&gt; &lt;class name="Person" mutable="false"&gt; &lt;id name="PersonCode" type="AnsiString" column="PERSONCODE"&gt; &lt;generator class="assigned" /&gt; &lt;/id&gt; &lt;property name="Name" type="String" column="PERSON_NAME" /&gt; &lt;property name="Surname" type="String" column="PERSON_SURNAME" /&gt; &lt;/class&gt; &lt;sql-query name="getpeople"&gt; &lt;return class="Person" /&gt; EXEC RS_DB.GETPERSONTEST &lt;/sql-query&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>Stored procedure:</p> <pre><code>CREATE OR REPLACE PROCEDURE RS_DB.GETPERSONTEST ( io_cursor IN OUT sys_refcursor ) IS BEGIN OPEN io_cursor FOR SELECT PERSONCODE, PERSON_NAME, PERSON_SURNAME FROM PEOPLE END GETPERSONTEST; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload