-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Calling a stored procedure from java persistence
PostPosted: Thu Feb 18, 2010 3:55 pm 
Newbie

Joined: Thu Feb 18, 2010 12:39 pm
Posts: 1
Hello,

I have this Oracle function in the database:

Code:
  type c_refcursor is ref cursor;

  FUNCTION testHibernateFunction
  RETURN c_refcursor
  IS
    ret_cur c_refcursor;
  BEGIN
    OPEN ret_cur FOR
      SELECT * FROM category;     
    return ret_cur;
  END testHibernateFunction;


I was wondering if there is anyway I can call this procedure without using @NamedNativeQuery. I tried this:

Code:
   List<Category> categories = this.entityManager
      .createNativeQuery("{? = call content_queries_pkg.testHibernateFunction}", Category.class)
      .setHint("org.hibernate.callable", "true")
      .setHint("org.hibernate.readOnly", "true")
      .getResultList();


But I got this error:

Code:
    java.sql.SQLException: Missing IN or OUT parameter at index:: 1


Is @NamedNativeQuery the only way stored procedures can be used with hibernate?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.