-->
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.  [ 3 posts ] 
Author Message
 Post subject: Delete record which is having composite key
PostPosted: Fri Mar 20, 2009 5:58 am 
Newbie

Joined: Fri Mar 20, 2009 4:19 am
Posts: 11
I am using Hibernet Asp.NET and i need help in delleting a record which is having composite key.

For Primary key I am using this code.

NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();
config.AddAssembly(typeof(CSTS.Main.Fund).Assembly);
factory = config.BuildSessionFactory();
session = factory.OpenSession();
Fund fund = session.Get<Fund>(txtCode.Text);
if (fund == null)
{
ShowMessageBox("This account information does no exisits!");
}
else
{
try
{
session.Transaction.Begin();
session.Delete(fund);
session.Transaction.Commit();
ShowMessageBox("Account Deleted");

For Composite key, What shd be in this below code.. I am having 3 column in composite key.

Fund fund = session.Get<Fund>(txtCode.Text);


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 20, 2009 6:31 am 
Regular
Regular

Joined: Wed Feb 11, 2009 10:58 am
Posts: 55
I think the cleanest way would be to create a class for your primary key. Then create an instance of this key class and pass it to the Get Function.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Fri Mar 20, 2009 8:14 am 
Newbie

Joined: Fri Mar 20, 2009 4:19 am
Posts: 11
Hi,

I would like to know, how can we delete record which is having composite key.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.