Try putting the TransactionScope around the whole initialisation (that calls the code several times). If things go bad, every such call uses not only a separate transaction, but also a separate session and thus a separate DB connection.
You should also not Flush directly, but only after all objects are created. -Markus 2009/11/27 JustinSpiteri <[email protected]>: > Gens, i have this query, i wrote an init script which basically calls > the following piece of code several times: > > //TransactionScope tx = new TransactionScope(); > > try > { > > // Assign identifiers to each ticket > foreach (Ticket t in tickets) > { > t.Id = EntityUtils.generateIdentifier("TK"); > > t.CreateAndFlush(); > } > > // tx.VoteCommit(); > //tx.Dispose(); > } > catch (Exception e) > { > // tx.VoteCommit(); > //tx.Dispose(); > } > > The first 85 - 90 or so ticket entity objects are persisted fine, > however the rest simply aren't persisted, with no error thrown at all, > as if nothing wrong happened. I've tried commenting the > transactionscope, uncommenting it, adding a "thread.sleep" (for fear > somethin was messing up with the timing), with no positive results. > What i have noticed is however that if i debug manually step by step, > the process seems to work. Anyone ever came across this issue?. > > Regards, > > Justin > > -- > > You received this message because you are subscribed to the Google Groups > "Castle Project Users" 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/castle-project-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Castle Project Users" 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/castle-project-users?hl=en.
