-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to call Oracle stored procedure from NHibernate?"
PostPosted: Wed Dec 06, 2006 9:21 am 
Beginner
Beginner

Joined: Fri Dec 01, 2006 5:16 am
Posts: 23
Location: India
Hi,

How to call Oracle stored procedure from NHibernate?"

Regards,

Raul


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 4:58 am 
Newbie

Joined: Wed Dec 06, 2006 12:58 pm
Posts: 6
Hi,

I have the same problem: http://forum.hibernate.org/viewtopic.php?t=968269.

I really feel alone with that, samples in documentation don't seem to work with Oracle.

Nicolas


Top
 Profile  
 
 Post subject: using Stored Procedures, NHibernate 1.2beta2 and Oracle
PostPosted: Wed Jan 10, 2007 10:25 am 
Newbie

Joined: Wed Jan 10, 2007 10:06 am
Posts: 1
Location: Germany
Hi,

I have spent most of the day fiddeling arround with oracle stored procedures. Here are my findings:

> Use 'call' not 'exec' as described in the manual
> enclose the parameters in brackets
> use the 'checks="none"' Attribute if the stored procedure does not return the affected rows count
> the only parameter(s) of your delete sp should be the pk field(s)
> in the update and insert sp, the parameters should be in the order you have defined the cols in you mapping file, exept of the pk field(s) - they should be last
> the order of the xml nodes should be in the right order - insert, update delete. Otherwise you get a XML Validation Error

The actual call executed by NHiberante, with the appropriate parameter values can be found in the log file - please check the file, to make sure that the parameters are correct :-)

Unfortunatly I have not worked out a way of naming the parameters! Maybe somebody can help us on that!

My Example Mapping File:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Data.Entities.CatTStaticdata,CatCommon" table="CAT_T_STATICDATA">

<!--<cache usage="read-write"/>-->
<id name="Id" column="ID" type="Int32" unsaved-value="0">
<generator class="sequence">
<param name="sequence">CAT_T_SEQ</param>
</generator>
</id>
<property column="CATEGORY" type="String" name="Category" not-null="true" length="50" />
<property column="NAME" type="String" name="Name" not-null="true" length="100" />
<property column="VALUE" type="Int32" name="Value" not-null="true" />
<property column="DESCRIPTION" type="String" name="Description" length="250" />

<sql-insert check="none">call MYGEN.INSERT_CAT_T_STATICDATA (?,?,?,?,?)</sql-insert>
<sql-update check="none">call MYGEN.UPDATE_CAT_T_STATICDATA (?,?,?,?,?)</sql-update>
<sql-delete check="none">call MYGEN.DELETE_CAT_T_STATICDATA (?)</sql-delete>

</class>
</hibernate-mapping>

Hope that these findings are helpful

_________________
Samy


Top
 Profile  
 
 Post subject: Re: How to call Oracle stored procedure from NHibernate?"
PostPosted: Thu May 14, 2009 8:01 am 
Newbie

Joined: Thu May 14, 2009 7:48 am
Posts: 2
Hi,

Did you try to use a stored procedure to load from as well? I have been trying to use a "read" stored procedure, but cant find a way to set the out parameter:

The mapping is defined like this:

Code:
  <sql-query name="selectAllActions_SP">
    <return alias="acimActions" class="NHAcimActions">
      <return-property name="actioncode" column="ACIM_ACTION_CODE"/>
      <return-property name="actiondesc" column="ACIM_ACTION_DESCRIPTION"/>
      <return-property name="actionsecs" column="ALLOWABLE_ELAPSE_SECS"/>
    </return>
    call ACIM_ACTIONS_PKG.get_all_acim_actions(?)
  </sql-query>


If I try to use this as a named query
Code:
IList allActions = session.GetNamedQuery("selectAllActions_SP")
                         .List()

I get an error:
Quote:
System.Collections.ListDictionaryInternal
Expected positional parameter count: 1, actual parameters: [] [call ACIM_ACTIONS
_PKG.get_all_acim_actions(?)]

Is there a way to set this?


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

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.