-->
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.  [ 4 posts ] 
Author Message
 Post subject: Manipulating Data With NHibernate via ObjectDataSource
PostPosted: Sat Jan 17, 2009 6:19 pm 
Newbie

Joined: Sat Jan 17, 2009 5:55 pm
Posts: 1
Location: Tbilisi, Georgia
Hello, everyone, it's my first post, I'm quite new with nhibernate, so, forgive me if my post looks too stupid :)

As a beginner I met quite a lot of problems, but I solved some of them already.
Though, there are few problems still remaining. I thought this might be a best place to get right answers.
As you might guess, I "try" to use an ObjectDataSource for viewing and manipulating my data.
First there was a sorting problem in a GridView, but I solved it.
Now I have an updating an deleting problem.

I'm using this statement in my DAO object:

public void Delete(T t)
{
Session.Delete(t);
}

I specify DataKeyNames property in a GridView, but something is missing and it doesn't work.

Same problem with update. I'm using SaveOrUpdate() method but no result.

Hope I'll get answers on my questions here, and these answers will help other beginners in advance :)
Thanks everyone...


Top
 Profile  
 
 Post subject: Re: Manipulating Data With NHibernate via ObjectDataSource
PostPosted: Thu Mar 18, 2010 7:21 am 
Newbie

Joined: Sun Oct 11, 2009 5:34 pm
Posts: 5
Hi,

this is me again, with another username :D
strange, that nobody answered this question.

here's the answer:

First you need to add Session.Flush() to the method, second, you cannot delete object straight from the data control, because this object isn't one from the Session, i.e. it's an "empty" object with the ID of the expected object, this is because of DataKeyNames = "ID" (when you reach Delete(T t) in the code this 't' has ID of the expected object) so what you need is get this ID, retrieve a "real" Session object with this ID and then delete id "by hand".

Cheers

Giorgi


Top
 Profile  
 
 Post subject: Re: Manipulating Data With NHibernate via ObjectDataSource
PostPosted: Thu Jun 03, 2010 8:12 am 
Newbie

Joined: Tue Mar 09, 2010 11:30 am
Posts: 7
Thanks, It certainly helped me ;-)


Top
 Profile  
 
 Post subject: Re: Manipulating Data With NHibernate via ObjectDataSource
PostPosted: Sat Jun 26, 2010 1:23 pm 
Newbie

Joined: Sun Oct 11, 2009 5:34 pm
Posts: 5
kmoo01 wrote:
Thanks, It certainly helped me ;-)


I'm so glad :)
Happy coding!

Giorgi


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