Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate generates update statement for all columns

Does NHibernate always generate update for all columns?

public class Person
{
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }
    public virtual string Address { get; set; }
}

Person p = Session.Load(1);
p.Name = "New Name";

Session.Flush();//Update for all columns, but I change only Name

Is it normal behavior for NHibernate or my mistake? I use Fluent NHibernate and AutoMapping.

like image 511
Andy Avatar asked Dec 16 '10 20:12

Andy


1 Answers

That is the default behavior, but you can make NH update modified columns only by adding dynamic-update="true" to your <class> mapping.

like image 173
Diego Mijelshon Avatar answered Oct 24 '22 14:10

Diego Mijelshon