3 Replies Latest reply on Sep 21, 2005 6:07 AM by Emmanuel Bernard

    How to call a stored procedure

    Mahesh Patil Newbie


      I have a problem while calling a Stored procedure. I am using Oracle as database and stored procedure returning a ref-curser.


      @SqlResultSetMapping(name="implicit", entities=@EntityResult(name="Text",fields = {
      @FieldResult(name="textId", column="text_id"),
      @FieldResult(name="sprache", column="sprache"),
      @FieldResult(name="text", column="text") }))
      @NamedNativeQuery(name="TextQ", queryString="{? = call pack_test_sp.ret_text()}", resultSetMapping="implicit" )

      public class Text {

      private int textId;
      private int sprache;
      private String text;

      @Id(generate = GeneratorType.NONE)
      public int getTextId() {

      return textId;

      public void setTextId(int id) {
      this.textId = id;

      public int getSprache() {

      return sprache;

      public void setSprache(int id) {
      this.sprache = id;

      public String getText() {

      return text;

      public void setText(String str) {
      this.text = str;


      //*******Stateless Bean*****
      public class ServerBean implements ServerRemote {

      private EntityManager manager;

      public String getText(int id) {
      String retValue = "";
      try {
      List list=null;
      Query q = manager.createNamedQuery("TextQ");
      Text txt = (Text)manager.find(Text.class,2);
      retValue = txt.getText();
      catch(Exception ex) {
      return retValue;


      I am getting following error while executing the query.....

      12:05:20,858 INFO [STDOUT] org.hibernate.QueryException: Expected positional pa
      rameter count: 1, actual parameters: [] [{? = call pack_test_sp.ret_text()}]
      at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryIm
      at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:16
      at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:140)
      at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:41)
      at ServerBean.getText(ServerBean.java:20)

      How do i call a stored procedure from a bean?
      Any help would be appreciated