Ok, first post on the list so bear with me.
I've been scratching my head, pulling my hair for a couple of days trying
to figure out what's going on. Unless I've done something wrong, I've found
a bug in ActionQueue.SortActions() which gets called last in
AbstractFlushingEventListener.FlushEntities(FlushEvent @event).
I have a class, lets call it Order, which has a one-to-may relationship to
OrderItems, both mapped individually in the config. I have two subclasses
of Order, let's call them FruitOrder and VegetableOrder decided by a
discriminator.
Upon saving one newly created instance of each order containing one
OrderItem each, followed by a flush the ActionQueue gets sorted in the
wrong order resulting in a foreign key violation exception.
Pseudocode:
var fruitOrder = new FruitOrder(new OrderItem[]{new OrderItem()});
var vegetableOrder = new VegetableOrder(new OrderItem[]{new Orderitem()});
session.Save(fruitOrder);
session.Save(vegetableOrder);
session.Flush(); // thows a foreign key violation exception
Looking at the ActionQueue during Flush() it first looks right,
FruitOrder, OrderItem, VegetableOrder, OrderItem
but after ActionQueue.Sort() is called in
AbstractFlushingEventListener.FlushEntities the OrderItems gets sorted
together resulting in
FruitOrder, OrderItem, OrderItem, VegetableOrder.
I've found an ugly way to go round this for now, forcing NHibernate to
process the ActionQueue prior to sorting it, by including a dummy object
with an identity id. In that case NHibernate seems to process the
ActionQueue prior to sorting it resulting in a successful Save.
I have a failing test for this (no solution yet unfortunately), but I'm not
sure how to submit the bug. From what I've read I need a trouble ticket
from Jira, but how do I get one?
--
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.
For more options, visit https://groups.google.com/groups/opt_out.