NHibernate mapping constraint violation?

Well I was right it was the mapping and I was right that it was stupid.

Up vote 0 down vote favorite share g+ share fb share tw.

I am doing something stupid and I just don't see it. I just want the class Party to have a set of PartyNames, using the mapping below, and am unable to insert a PartyName with an FK constraint violation. Will post the object code if necessary but suspect it is the mapping.

Cheers, Berryl Error and test code NHibernate: INSERT INTO Parties (Type, PartyId) VALUES ('PERSON', @p0);@p0 = 229376 Type: Int32 (0) NHibernate: INSERT INTO PartyNames (PartyId, RequiredName, EverythingElse, ContextUsed, Salutation, EffectiveStart, EffectiveEnd, PartyNameId) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7); @p0 = 229376 Type: Int32 (0), @p1 = 'Hesh' Type: String (50), @p2 = 'Berryl;;;' Type: String (4000), @p3 = 'Stack Overflow Profile' Type: String (50), @p4 = 'Fellow Geek' Type: String (20), @p5 = 7/28/2011 1:21:19 PM Type: DateTime (0), @p6 = 12/31/9999 11:59:59 PM Type: DateTime (0), @p7 = 262144 Type: Int32 (0) Test 'Parties.Data.Impl.NHib.Tests.TestFixtures. SqlServerCommandExecutor. GenerateTestData' failed: NHibernate.Exceptions.

GenericADOException : could not insert: Parties.Domain.Names. PartyName#262144SQL: INSERT INTO PartyNames (PartyId, RequiredName, EverythingElse, ContextUsed, Salutation, EffectiveStart, EffectiveEnd, PartyNameId) VALUES (?,? ,?

,? ,? ,?

,? ,? ) ----> System.Data.SqlClient.

SqlException : The INSERT statement conflicted with the FOREIGN KEY constraint "Party_PartyName_FK". The conflict occurred in database "PartyDomainDb", table "dbo. Parties", column 'PartyId'.

Test, Explicit public void GenerateTestData() { NameSeeds.Initialize(); var party = new Person(); using (Scope(true)) { _session. SaveOrUpdate(party); NameSeeds.DevName. Party = party; NameSeeds.LegalName.

Party = party; Assert. That(party.Names.Count(), Is. EqualTo(2)); _session.

SaveOrUpdate(party); } } Mapping (Party) Mapping (PartyName) nhibernate nhibernate-mapping link|improve this question edited Jul 30 '11 at 3:50 asked Jul 28 '11 at 20:45Berryl3,3491241 88% accept rate.

It's hard to answer without the code for NameSeeds and Scope. – Diego Mijelshon Jul 29 '11 at 2:54 @Diego Mijelshon. See updated post.

I also added the code to maintain the bidirectional relationship as well - I know its a bit of code for an SO question. Cheers – Berryl Jul 29 '11 at 5:03.

Well I was right it was the mapping and I was right that it was stupid I had the column name on the foreign key mixed up! ** WRONG, what I had ** RIGHT, what I umm, meant.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions