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