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: How to connect to stored procedures in nhibernate
PostPosted: Wed Jan 30, 2008 10:10 am 
Newbie

Joined: Sun Jan 27, 2008 4:26 pm
Posts: 18
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I am using stored procedure in my application .In MY database we have table called DVBChannel.This table contains DVBChannelID,DVBChannelNo,DVBChannelName,URLType,DVBStatusID,Description.When i want to add channel no and name into the database i want to check first wether it is existing or not.so i wrote one strored procedure.
Can u pleade help me this because i am new to nhibernate.
Here it is my stored procedure
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
create procedure spCheckDuplicate
@DVBChannelNo int,
@DVBChannelName nvarchar(60),
@F int output
as
BEGIN
select @F=count(*) from DVBChannel where DVBChannelNo=@DVBChannelNo
and DVBChannelName=@DVBChannelName
END


Hibernate version:
NHibernate 1.2.1 GA

Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="FreeView" assembly="FreeView" default-access="property">
<class name="DVBChannel" lazy="false" table="DVBChannel" >
<id name="DVBChannelID" column="DVBChannelID" type="int">
<generator class="native"></generator>
</id>
<property name="DVBChannelNo" column="DVBChannelNo" type="int"/>
<property name="DVBChannelName" column="DVBChannelName" type="string"/>
<property name="DVBChannelURL" column="DVBChannelURL" type="string"/>
<many-to-one name="DVBStatus" class="DVBStatus" column="DVBStatusID" cascade="none" not-null="true" fetch="select"/>
<property name="EPGDataFile" column="EPGDataFile" type="string"/>
<property name="Description" column="Description" type="string"/>
<loader query-ref="spCheckDuplicate"/>
</class>
<sql-query name="spCheckDuplicate">
<return alias="DVBChannel" class="DVBChannel">
<return-property name="F" column="F"/>
I donot know here how to write mapping and i want to check if it is 1 the value is existing or its not,so i want to check programetically.
</return>
exec spCheckDuplicate ?
</sql-query>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


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.