I wrote a class and mapped it with “assigned” id generator, but it doesn’t work, entities can’t saved to the db, when I using native(mysql auto increase int column), it runs well, is there any problem?
I browsed the source of nhibernate, found these:
NHibernate.Event.Default.AbstractSaveEventListener. PerformSaveOrReplicate(), line 300
Code:
if (!useIdentityColumn)
{
source.ActionQueue.AddAction(new EntityInsertAction(id, values, entity, version, persister, source));
}
This means entities without identity column will always be delay saved, and doesn’t check shouldDelayIdentityInserts.
I changed it to:
Code:
if (!useIdentityColumn)
{
EntityInsertAction insert = new EntityInsertAction(id, values, entity, version, persister, source);
if (!shouldDelayIdentityInserts)
source.ActionQueue.Execute(insert);
else
source.ActionQueue.AddAction(insert);
}
Then, my entities can be saved to db properly.
[/code]