Hello,
I am using FluentNHibernate 2.0.1 and NHibernate 4.0.3.GA.
I am testing the Automapping Feature.
When introducing the "Version" Property in one of my entities (Person) and 
trying to insert a new Person,
I get an exception in the NHibernate.Engine.Nullability class:
*{"not-null property references a null or transient value 
ArgosDBTestClient.Models.Person.Version"}*
This makes sense, since version has a null reference and the database 
column is created via FluentNHibernate with "Not Null"

Nevertheless the version property is unfortunately not working out of the 
box, as it should behave simila as the ID property does (which has a value 
of 0 and is not included in the Insert statement)

What would be the best way to solve this issue (probably via Change-Request 
to the FNH Source Code).
Please tell me your opinions and thoughts on this issue.
Thanks alot
Harry

My code is as follows:

using System;
using ArgosDBTestClient.Models;
using FluentNHibernate.Automapping;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Tool.hbm2ddl;
using System.Collections.Generic;
using NHibernate.Util;
 
 
namespace ArgosDBTestClient
{
    public class Program
    {
        public static ISessionFactory SessionFactory;
 
        private static void Main()
        {
            SessionFactory =
                Fluently.Configure()
                    .Database(MsSqlConfiguration.MsSql2008
                        
.ConnectionString("SERVER=192.168.0.10;DATABASE=ArgosDBTestClient;UID=sa;PWD=xxx"))
                    .Mappings(
                        m =>
                            m.AutoMappings.Add(
                                AutoMap.AssemblyOf<Person>().Where(type => 
type.Namespace.EndsWith("Models"))))
                    .BuildSessionFactory();
 
            new Tests().SomeTests();
        }
    }
 
    class Tests
    {
        public void SomeTests()
        {
            var harry = new Person();
            harry.FirstName = "Harald";
            harry.LastName = "Schwaiger";
 
            ISession session = Program.SessionFactory.OpenSession();
            session.Save(harry);
            
            Console.ReadLine();
        }
    }
}


My Person Entity is as follows:

namespace ArgosDBTestClient.Models
{
    public class Person
    {
        public virtual int Id { get; set; }
        public virtual bool Archived { get; set; }
 
        public virtual byte[] Version { get; protected set; }
 
        public virtual string Salutation { get; set; }
        public virtual string Title1 { get; set; }
        public virtual string Title2 { get; set; }
        public virtual string FirstName { get; set; }
        public virtual string LastName { get; set; }



-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fluent-nhibernate+unsubscr...@googlegroups.com.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
Visit this group at http://groups.google.com/group/fluent-nhibernate.
For more options, visit https://groups.google.com/d/optout.

Reply via email to