Are you 100% sure that your schema's been created as you think?  The
following two snippets look contradictory to me:

 

The table's are created: 

create table InheritedAddresses ( 

        Id UNIQUEIDENTIFIER not null, 

       ZipCode TEXT, 

       Town TEXT, 

       AddressLine1 TEXT, 

       Country TEXT, 

       Employee_id UNIQUEIDENTIFIER, 

       primary key (Id), 

       constraint FK1452CB75BF9AA6F3 foreign key (Employee_id) 

references Employees 

    ) 

 

NHibernate.Exceptions.GenericADOException : could not insert 

collection: 

[ProjectTracker.Domain.Employees.Employee.Addresses#b0fd8b90-7a2d-4283- 

abf9-a1a5011ae0d5][SQL: UPDATE InheritedAddresses SET Employee_id = 

@p0 WHERE Id = @p1] 

  ----> System.Data.SQLite.SQLiteException : SQLite error 

no such column: Employee_id

 

 

Re. the Inverse(), I would personally think about giving Address a
many-to-one to Employee and then mapping it as Inverse which would allow
NHibernate to avoid the update statement; without the many-to-one,
though, it is correct to omit Inverse.

 

/Pete

 

 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Peter Forstmeier
Sent: 19 April 2013 16:19
To: nhusers
Subject: [nhusers] Wrong Mapping

 

Hi List,

i have no idea what's wrong with this mapping.

 

 

public EmployeeMapping()

{

........

HasMany(x => x.Addresses).Not.LazyLoad();

 

}

 

public class BaseAdressMapping : ClassMap<Address>

{

        public BaseAdressMapping()

        {

            Table("InheritedAddresses");

            Id(x =>

x.Id).GeneratedBy.GuidComb().UnsavedValue("00000000-0000-0000-0000-00000
0000000");

            Map(x =>

x.ZipCode).Length(DefaultFieldDescription.DefaultIdLength);

            Map(x =>

x.Town).Length(DefaultFieldDescription.DefaultStringColumnLength);

            Map(x =>

x.AddressLine1).Length(DefaultFieldDescription.DefaultStringColumnLength
);

            Map(x =>

x.Country).Length(DefaultFieldDescription.DefaultStringColumnLength);

 

      }

  }

 

[Test]

public void Employee()

{

      var factory = MySQLiteSessionFactory.CreateSessionFactory();

                  var adr1 = new Address() {

                        ZipCode = "aa"

                  };

 

var adr2 = new Address() {

                  ZipCode = "aa"

                   };

 

                  var list =  new
System.Collections.Generic.List<Address>();

                  list.Add(adr1);

                  list.Add(adr2);

 

      

PersistenceSpecification<ProjectTracker.Domain.Employees.Employee>(facto
ry.OpenSession())

 

            .CheckProperty(c => c.CreatedAt, DateTime.Today)

            .CheckList(c => c.Addresses,list)

 

            VerifyTheMappings();

}

 

The table's are created:

create table InheritedAddresses (

        Id UNIQUEIDENTIFIER not null,

       ZipCode TEXT,

       Town TEXT,

       AddressLine1 TEXT,

       Country TEXT,

       Employee_id UNIQUEIDENTIFIER,

       primary key (Id),

       constraint FK1452CB75BF9AA6F3 foreign key (Employee_id)

references Employees

    )

 

NHibernate.Exceptions.GenericADOException : could not insert

collection:

[ProjectTracker.Domain.Employees.Employee.Addresses#b0fd8b90-7a2d-4283-

abf9-a1a5011ae0d5][SQL: UPDATE InheritedAddresses SET Employee_id =

@p0 WHERE Id = @p1]

  ----> System.Data.SQLite.SQLiteException : SQLite error

no such column: Employee_id

 

Any idea's

Thanks

Peter

 

 

-- 

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]
<mailto:[email protected]> .

To post to this group, send email to [email protected]
<mailto:[email protected]> .

Visit this group at http://groups.google.com/group/nhusers?hl=en-US
<http://groups.google.com/group/nhusers?hl=en-US> .

For more options, visit https://groups.google.com/groups/opt_out
<https://groups.google.com/groups/opt_out> .

 

 

-- 
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?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to