-->
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: Update one column on a table
PostPosted: Wed Jul 15, 2009 2:32 am 
Newbie

Joined: Wed Jul 15, 2009 2:24 am
Posts: 2
Let's say I have a model such as:

Code:
public class Person
{
      public virtual int Id { get; set; }
      public virtual string FirstName { get; set; }
      public virtual string LastName { get; set; }
      public virtual bool Active { get; set; }
}


... and of course the appropriate hbm mapping.

Is there a way for me to get NHibernate to do an update to the database... but only on a single column... for example the Active column?

i.e. SQL...

Code:
UPDATE [Person]
SET [Active] = @Active
WHERE [Id] = @Id


Top
 Profile  
 
 Post subject: Re: Update one column on a table
PostPosted: Wed Jul 15, 2009 6:38 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Put update="false" in the property mapping.

http://nhforge.org/doc/nh/en/index.html#mapping-declaration-property

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Re: Update one column on a table
PostPosted: Wed Jul 15, 2009 4:46 pm 
Newbie

Joined: Wed Jul 15, 2009 2:24 am
Posts: 2
Yup, that could be done... however, I'd like to be able to update all the fields in the "normal" update process.... however deletes, which I'd like to treat as a soft delete, I was wondering if there's some way for me to do just an update on the Active column only.


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.