-->
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.  [ 7 posts ] 
Author Message
 Post subject: ISession.Delete(object obj) not working
PostPosted: Thu Oct 21, 2010 3:36 pm 
Newbie

Joined: Thu Oct 21, 2010 3:03 pm
Posts: 5
Location: India
I am very new to NHibernate.
I have created test project, and trying to use some NH methods, consider table TestTable1, i m able to get all records in grid, save new records but no able to delete the records from db. Not even getting any kind of exception..
using the method as ISession.Delete(tt1); //tt1 is retrieved using ISession.Load<TestTable1>(1) //1 being an Id of the record i want to delete. I get TestTable1 object with id = 1 but it does not delete that record from db.

_________________
No one will manufacture a lock without key, similarly god will never give problems without a solution.


Top
 Profile  
 
 Post subject: Re: ISession.Delete(object obj) not working
PostPosted: Fri Oct 22, 2010 7:53 am 
Newbie

Joined: Wed Sep 08, 2010 6:38 am
Posts: 9
Do you call Session.Flush() afterwards?


Top
 Profile  
 
 Post subject: Re: ISession.Delete(object obj) not working
PostPosted: Sat Oct 23, 2010 4:42 am 
Newbie

Joined: Thu Oct 21, 2010 3:03 pm
Posts: 5
Location: India
No i don't do that. I will try that and let you know.
Thanks.

_________________
No one will manufacture a lock without key, similarly god will never give problems without a solution.


Top
 Profile  
 
 Post subject: Re: ISession.Delete(object obj) not working
PostPosted: Sat Oct 23, 2010 5:55 am 
Newbie

Joined: Thu Oct 21, 2010 3:03 pm
Posts: 5
Location: India
markybry@gmail.com wrote:
Do you call Session.Flush() afterwards?


I tried calling Session.Flush() after Session.Delete() method. But no luck. Still record does not get deleted.

_________________
No one will manufacture a lock without key, similarly god will never give problems without a solution.


Top
 Profile  
 
 Post subject: Re: ISession.Delete(object obj) not working
PostPosted: Mon Oct 25, 2010 6:29 am 
Newbie

Joined: Wed Sep 08, 2010 6:38 am
Posts: 9
If you are using transactions , make sure you call transaction.Commit();


Top
 Profile  
 
 Post subject: Re: ISession.Delete(object obj) not working
PostPosted: Mon Oct 25, 2010 4:30 pm 
Newbie

Joined: Thu Oct 21, 2010 3:03 pm
Posts: 5
Location: India
Problem was with the session. I was opening session for every call. Now i have retrieve session using base constructor. It solved the problem.

_________________
No one will manufacture a lock without key, similarly god will never give problems without a solution.


Top
 Profile  
 
 Post subject: Re: ISession.Delete(object obj) not working
PostPosted: Wed Oct 27, 2010 9:54 am 
Newbie

Joined: Wed Sep 08, 2010 6:38 am
Posts: 9
Ah i see.

You might want to take a look at the unit of work pattern to manage your sessions.

http://nhforge.org/wikis/patternsandpra ... ttern.aspx


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