Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Calling Stored procedure from Hibernate

 
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
 
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;

 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic