Hi!

Looks like I'm not running out of confusion or problems anytime soon :)

Now I'm inserting an entity with a list of other entities (one-to-many) which I have configured with 'cascade="all"'. I'm using 'generator="assigned"' ids, so no roundtrip to the database is necessary to obtain any IDs and yet, NHibernate first inserts all entities in the list, then inserts the root entity, then updates all entities in the list, reassigning the root entities key (a no-change operation):

   INSERT INTO Children(Id, ParentId)
   VALUES (1, 99);
   INSERT INTO Children(Id, ParentId)
   VALUES (2, 99);

   INSERT INTO Parents(Id)
   VALUES(99);

   UPDATE Children
   SET ParentId = 99
   WHERE Id = 1;
   UPDATE Children
   SET ParentId = 99
   WHERE Id = 2;

And during deletes, NHibernate first attempts to set the ParentId of all children to NULL via an UPDATE, then deletes the Parent, then deletes the children. Except, well, setting the ParentId to NULL is a constraint violation (and NHibernate knows it through the mapping files!), so it crashes and burns once again. By the way, the ParentId NOT NULL constraint comes straight out of NHibernate's SchemaExport.

I'm running into so many easily reproducible and fundamental issues that it leaves me a bit confused. The NHibernate website is touting that this is a mature and proven product. Are the 3.x maybe still betas or not as thoroughly tested?

Greetings,
-Markus-

--
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to