Tips and Tricks in a world of Mix



using (ISession Session = NHibernateSessionProvider.GetSession("MYDB"))
using (NHibernate.ITransaction Tran = Session.BeginTransaction(System.Data.IsolationLevel.Serializable))
IQuery query = (IQuery)Session.GetNamedQuery("MYSPNAME").SetResultTransformer(Transformers.AliasToBean(typeof(Sample))); ;
query.SetParameter("p_1", 1);
query.SetParameter("p_2", 12345678);
query.SetDateTime("p_3", null);

IList result = query.List();


Model :

public class Sample : Entity
public virtual int Id { get; set; }
public virtual int SerialNumber { get; set; }




<?xml version=”1.0″ encoding=”utf-8″ ?>
<!– Generated by MoreGen 28-Apr-2008 11:27:28 –>
<hibernate-mapping xmlns=”urn:nhibernate-mapping-2.2″ assembly=”ASSEMBLYNAME”
<class name=”Sample” table=”MYSPNAME” lazy=”true”>
<id name=”Id” column=”ID”>
<generator class=”native” />
<property name=”SerialNumber” column=”serial_number” />
<loader query-ref=”MYSPNAME”/>
<sql-query name=”MYSPNAME” >
<return alias=”MYSPNAME” class=”Sample”>
<return-property name=”SerialNumber” column=”serial_number” />

exec [OLTP_PACK.GET_SAMPLE_LIST]  :p_1 , :p_2 , :p_3



got an advise to try out this post
didn't work either..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: