Hi,
I am using JPA with Hibernate to call an Oracle Stored Procedure (SP).
The problem i am facing is that, instead of returning a set of
different rows, the SP is returning the
same row multiple times. The SP returns a ref-cursor and the out parameter is the first one in the SP call. The sp runs fine if i run it in sql developer i.e. it is giving me a set of different rows. Can anyone please help out?
Thanks in advance.
The hibernate hbm file contains the below mapping :-
Code:
<hibernate-mapping package="com.abc.domain.bo.helper">
<class name="com.abc.domain.bo.helper.MyRequestList" >
<id name="myRequestId" >
<generator class="assigned" />
</id>
<property name="myRequestId" column="MY_REQUEST_ID" insert="false" update="false"/>
<property name="submittedById" column="SUBMITTED_BY_ID" />
<property name="submittedDate" column="SUBMITTED_DT" />
<property name="processStatusCode" column="PROCESS_STATUS_CD" />
<property name="latestIn" column="LATEST_IN" />
<loader query-ref="myRequestList_query" />
</class>
<sql-query name="myRequestList_query" callable="true">
<return alias="myRequestList" class="com.abc.domain.bo.helper.MyRequestList">
<return-property name="myRequestId" column="MY_REQUEST_ID" />
<return-property name="submittedById" column="SUBMITTED_BY_ID" />
<return-property name="submittedDate" column="SUBMITTED_DT" />
<return-property name="processStatusCode" column="PROCESS_STATUS_CD" />
<return-property name="latestIn" column="LATEST_IN" />
</return>
{ call spm_myresults_get(?, :reqId, :orderBy) }
</sql-query>
</hibernate-mapping>
And, my Java code is shown below :-
Code:
EntityManager em = getEntityManager();
Query query = em.createNamedQuery("myRequestList_query");
query.setParameter("reqId", clientId);
query.setParameter("orderBy", orderByClause);
List<MyRequestList> results = query.getResultList();
Regards,
Sid