Пример #1
0
        public void OnPostInsert(PostInsertEvent evt)
        {
            String entityName = evt.Persister.EntityName;

            if (verCfg.EntCfg.IsVersioned(entityName))
            {
                AuditSync verSync = verCfg.AuditSyncManager.get(evt.Session);

                IAuditWorkUnit workUnit = new AddWorkUnit(evt.Session, evt.Persister.EntityName, verCfg,
                                                          evt.Id, evt.Persister, evt.State);
                verSync.AddWorkUnit(workUnit);

                if (workUnit.ContainsWork())
                {
                    GenerateBidirectionalCollectionChangeWorkUnits(verSync, evt.Persister, entityName, evt.State,
                                                                   null, evt.Session);
                }

                //Simon - TODO - Correct/clarify this:
                // it appears that the AuditSyncManager's transaction.RegisterSynchronization(verSync);
                // does not lead to calling the verSync's synchronization methods (Before and AfterCompletion
                // so I will call this manually. The problem that I found is that AdoTransaction's Commit method
                // is not called at all. Could this be because of Spring.NET?
                // When corrected, change also in AuditSync the Flush in BeforeCompletion.
                //verSync.BeforeCompletion();
            }
        }
Пример #2
0
        public virtual void OnPostInsert(PostInsertEvent evt)
        {
            var entityName = evt.Persister.EntityName;

            if (!VerCfg.EntCfg.IsVersioned(entityName))
            {
                return;
            }
            checkIfTransactionInProgress(evt.Session);

            var auditProcess = VerCfg.AuditProcessManager.Get(evt.Session);
            var workUnit     = new AddWorkUnit(evt.Session, evt.Persister.EntityName, VerCfg,
                                               evt.Id, evt.Persister, evt.State);

            auditProcess.AddWorkUnit(workUnit);
            if (workUnit.ContainsWork())
            {
                generateBidirectionalCollectionChangeWorkUnits(auditProcess, evt.Persister, entityName, evt.State,
                                                               null, evt.Session);
            }
        }