-->
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.  [ 5 posts ] 
Author Message
 Post subject: I just want to update a field in my customer table.
PostPosted: Fri Sep 30, 2005 8:56 am 
Newbie

Joined: Sat Sep 17, 2005 5:48 am
Posts: 9
I have a table in which i want to do an update to. I just dont know how to do it with nhibernate.

For eg, I have a customer table, one of the fields is name and I want to simply use the customer id, which I have on hand to simply change the name if I wanted to. The sql could be something like

Update customer set name = "Joe Bloe" where customer_id = 23

But how do you do such a simple thing with nHibernate. Do I have to use HQL? Can someone give me a clue.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 11:51 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
This is not possible with NHibernate; a session can only save loaded entities.

You may either load the entity first or use classic SQL (not recommended if the operation is not performance-critical...)

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 7:33 pm 
Newbie

Joined: Sat Sep 17, 2005 5:48 am
Posts: 9
The problem is that all of this occurs in a transaction and i need to get the returned id from one insert before I insert another. What I do i go back to the table that I passed by and update it with the id after its already been inserted. How could i do this with nihibernate then.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 01, 2005 8:07 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Can you post your code? (between OpenSession() and session.Close())

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 9:13 pm 
I removed the problem by really learning how to use nHibernate the way it was meant to be used, but thanks anyway.


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