Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling Stored procedure from Hibernate

 
Durgha Prasad Sriram
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Craig Taylor
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Durgha Prasad Sriram
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic