Nhibernate Fluent domain Object with Id(x => x.id).GeneratedBy.Assigned not saveable

Posted by urpcor on Stack Overflow See other posts from Stack Overflow or by urpcor
Published on 2009-10-14T14:32:10Z Indexed on 2010/05/01 17:57 UTC
Read the original article Hit count: 201

Hi there,

I am using for some legacy db the corresponding domainclasses with mappings. Now the Ids of the entities are calculated by some stored Procedure in the DB which gives back the Id for the new row.(Its legacy, I cant change this) Now I create the new entity , set the Id and Call Save. But nothing happens. no exeption. Even NH Profiler does not say a bit. its as the Save call does nothing. I expect that NH thinks that the record is already in the db because its got an Id already. But I am using Id(x => x.id).GeneratedBy.Assigned() and intetionally the Session.Save(object) method.

I am confused. I saw so many samples there it worked.

does any body have any ideas about it?

public class Appendix
{
    public virtual int id { get; set; }
    public virtual AppendixHierarchy AppendixHierachy { get; set; }
    public virtual byte[] appendix { get; set; }
}       

public class AppendixMap : ClassMap<Appendix>
{
    public AppendixMap ()
    {
        WithTable("appendix");
        Id(x => x.id).GeneratedBy.Assigned();
        References(x => x.AppendixHierachy).ColumnName("appendixHierarchyId");
        Map(x => x.appendix);
    }
}

© Stack Overflow or respective owner

Related posts about fluent-nhibernate

Related posts about nhibernate