Forums Register Login

Calling Stored procedure from Hibernate

+Pie Number of slices to send: Send
Oracle Procedure:

CREATE OR REPLACE
PROCEDURE INSERT_ROW_PROC AS
BEGIN
insert into slc_message(message_id, subject, message) values(41,'insert row','insert row');

END INSERT_ROW_PROC;

Hibernate mapping:

<hibernate-mapping>
<class name="com.citi.gcgna.cdf.slc.presentation.jfp.borrower.subapps.messages.dao.MessageSP">
<id name="messageId" type="long" />
<property name="subject" type="java.lang.String" />
<property name="message" type="java.lang.String" />
</class>
<sql-query name="insert_SP" callable="true">
<return alias="mess" class="com.citi.gcgna.cdf.slc.presentation.jfp.borrower.subapps.messages.dao.MessageSP">
</return>

{ call INSERT_ROW_PROC() }
</sql-query>
</hibernate-mapping>

Calling Code:

Query q = session.getNamedQuery("insert_SP");
q.list();

I am getting ERROR org.hibernate.util.JDBCExceptionReporter - Invalid column index and could not execute query message.
Could you please help me to solve this issue?

Thanks,
Durgha Prasad
+Pie Number of slices to send: Send
Preliminaries:

Please use the bbcode [ code ] and [ / code ] to demarcate your code as it makes reading things much easier.

Your issue :

<guess> I believe it's related to not returning a result set for the query.list() operation - try replacing it with a query.executeUpdate() (not sure) or modify your stored proudure to return a "select 1" or other simple result set. </guess>
+Pie Number of slices to send: Send
Thanks for your reply, I am getting native sql exception if I use executeUpdate method.

Could you please post calling complete oracle store procedure from hibernate sample code?

Thanks and Regards,
Durgha prasad.


Craig Taylor wrote:Preliminaries:

Please use the bbcode [ code ] and [ / code ] to demarcate your code as it makes reading things much easier.

Your issue :

&lt;guess&gt; I believe it's related to not returning a result set for the query.list() operation - try replacing it with a query.executeUpdate() (not sure) or modify your stored proudure to return a "select 1" or other simple result set. &lt;/guess&gt;

 
These are the worst of times and these are the best of times. And this is the best tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1901 times.
Similar Threads
Facing the problem while reterving the resultsets in java from named query function in hibernate
Invalid Mapping Exception while inserting data through hibernate
Working Example of Hibernate Call to an Oracle Stored Proc.
one-to-many relation
Insert via Hibernate and Stored Procs
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:45:55.