I just found a solution - I registered RhinoTransactionFacility instead of original Castle ATM facility and transactions started to work.
On 23 Bře, 08:38, Filip Kinsky <[email protected]> wrote: > I'm just trying to use ATM with this solution, but the changes aren't > commited into database for some reason I'm not able to figure out. I > register ATM + transaction manager like this: > > //register Automatic Transaction Management facility > > Container.AddFacility<Castle.Facilities.AutomaticTransactionManagement.TransactionFacility> > (); > //register transaction manager for ATM > Container.Register > (Component.For<Castle.Services.Transaction.ITransactionManager>() > > .ImplementedBy<Castle.Services.Transaction.DefaultTransactionManager> > ()); > > and decorate the service class appropriately: > > [Transactional] > public class UserAdminService : IUserAdminService > { > ... > > [Transaction(TransactionMode.Requires)] > public User CreateNewUser(string username, string password, > string > firstName, string lastName) > { > var u = new User(username) > { > PasswordHash = > GetPasswordHash(password), > FirstName = firstName, > LastName = lastName > }; > userRepo.Save(u); > return u; > } > } > > now when I call the action, the new User is not persisted into DB. I > turned logging of NHibernate.SQL to DEBUG to see the actual SQL, but > there's no INSERT statement for this operation present. So it looks > like there's some flush missing - the flush should be handled by > UnitOfWorkApplication in end-request shouldn't it? The insert > operation was performed and commited when I appended > UnitOfWork.CurrentSession.Flush() after userRepo.Save() call so I > assume I have something broken in UoWApplication or misunderstood > something again :) > Is there any idea what should I try to make my UoWApp flush the > changes on request end? > > On 20 Bře, 16:29, Ayende Rahien <[email protected]> wrote: > > > That is the expected behavior. You can either use ATM or With.TransactionI > > recommend ATM > > > On Fri, Mar 20, 2009 at 11:24 AM, Filip Kinsky <[email protected]> wrote: > > > > I just started new MS MVC project and wanted to use > > > UnitOfWorkApplication. The application works ok until I want to write > > > some changes to DB. I thought the UnitOfWorkApplication will > > > automatically flush and commit all changes I made to DB if no > > > exception is thrown, but it doesn't work like that in my project. Do I > > > need to use With.Transaction in my write-controllers/actions/services > > > or Castle ATM etc or should the UoWApp work as I mentioned (flush > > > +commit on request end)? > > > > I currently have controller action like this, but no changes are > > > persisted in DB when I invoke the action. > > > > public JsonResult CreateSomeUser() > > > { > > > var u = userAdminService.CreateNewUser("userX", > > > "x", > > > "x", "x"); > > > return Json(new {success = true, id = u.Id}); > > > } > > > > ... > > > > public User CreateNewUser(string username, string password, > > > string > > > firstName, string lastName) > > > { > > > var u = new User(username) > > > { > > > PasswordHash = > > > GetPasswordHash(password), > > > FirstName = firstName, > > > LastName = lastName > > > }; > > > userRepo.Save(u); > > > return u; > > > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" 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/rhino-tools-dev?hl=en -~----------~----~----~----~------~----~------~--~---
