Im speculating, that because i have the same properties on both superclass and subclass, it is not ommitting the values to the right object.
It is creating the rows in the database correctly, but fails to add the company id right. It should cast to the Company, before omitting to the superclass and it could freely add to the subclass.
This is the generated SQL (the actual model has more parameters than i have in the example):
Code:
NHibernate: INSERT INTO Company (VATIN, RegistrationCode, BusinessTypeClvId, StateClvId, Name) VALUES (@p0, @p1, @p2, @p3, @p4); select SCOPE_IDENTITY(); @p0 ='19827744', @p1 = '123456789', @p2 = '360', @p3 = '358', @p4 = '4home.ee'
NHibernate: INSERT INTO Client (ClientCardCode, PaymentDue, CreditLimit, StateClvId, ExtraInfo, StartDate, EndDate, CompanyId) VALUES (@p0, @p1, @p2, @p3, @p4,@p5, @p6, @p7); @p0 = '', @p1 = '', @p2 = '', @p3 = '358', @p4 = '', @p5 = '18.12.2006 10:00:21', @p6 = '', @p7 = '109'
client id: 109, company id: 0 (Console.WriteLine)
NHibernate: INSERT INTO Person (FirstName, LastName, Code, BirthDate, JobTitleClvId, SexClvId) VALUES (@p0, @p1, @p2, @p3, @p4, @p5); select SCOPE_IDENTITY(); @p0 = 'Jama', @p1 = 'JamaPerekonnanimi', @p2 = '1234567', @p3 = '', @p4 = '', @p5 = '359'
NHibernate: INSERT INTO Contact (ClientId, StateClvId, EmployeeId, StartDate, EndDate, PersonId) VALUES (@p0, @p1, @p2, @p3, @p4, @p5); @p0 = '109', @p1 = '358', @p2 = '', @p3 = '18.12.2006 10:00:21', @p4 = '', @p5 = '60'
Could a solution be to somehow set, what the joined-subclasses Id column is ? i havent found any option to set it unfortunately.