On NH 4.0.2, this works perfectly:

public class Sample
{
        public int Id { get; set; }
        public int? RowVersion { get; set; }
        public string Name { get; set; }
}


var mapper = new ModelMapper();
mapper.Class<Sample>(x =>
{
        x.Table("sample");
        x.Id(y => y.Id, y => y.Generator(Generators.Identity));
        x.Version(y => y.RowVersion, y => y.UnsavedValue(null));
        x.Property(y => y.Name);
});
 
cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());


session.Save(new Sample {Name = "ABC"});
session.Flush();
session.Query<Sample>().ToList();


And also this:

x.Version(y => y.RowVersion, y => y.UnsavedValue(-1));


session.Save(new Sample { Name = "ABC", RowVersion = -1 });


So, I'd say it's something in your code.

RP

On Friday, February 20, 2015 at 2:08:53 AM UTC, Alexander Zaytsev wrote:
>
> Can anyone log an issue in JIRA? We need a reproducible test which 
> demonstrates a problem
>
> On Thu, Feb 19, 2015 at 6:48 AM, alrhr <[email protected] <javascript:>> wrote:
>
>> Just found out what the problem was: using UnsavedValue(-1) or 
>> UnsavedValue(null) in the mapping file as proposed in different sources 
>> (e.g. NH Beginners Guide) is no longer allowed in NHibernate 4. It must be 
>> changed into UnsavedValue(0) or completely omitted. Is this a bug or a 
>> feature?
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "nhusers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/nhusers.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to