Check out what S#arp Architecture is doing. http://code.google.com/p/sharp-architecture/
My original blog post after hacking through multiple session factories can be found here http://bit.ly/26x6rl. The gist is creating sessions with a key and using that key to differentiate between each of your sessions and then a quick attribute on your repositories so that they stay straight with the factory. I haven't looked at S#arp's builds in a few weeks, but I know Billy and Co. took and built it up a ton from what I had done. Give it a browse--if nothing else, it may spark some ideas to meet your needs. -dl -- David R. Longnecker blog: http://blog.tiredstudent.com twitter: dlongnecker "Good design is a Renaissance attitude that combines technology, cognitive science, human need, and beauty to produce something." - Paola Antonelli On Wed, Aug 19, 2009 at 2:51 PM, Beefy <[email protected]> wrote: > > I have two databases: A legacy one and a new one that is being > generated by NHibernate for me. There's a lot of data moving around in > these cases into new tables, etc. The way I WAS handling this in my > own code was to have two sets of repositories. I would load data with > the legacy repositories and save it with my new repositories. > > I'm running into issues with that behavior with FNH though... > > I'm doing the exact same thing, something like this: > > // Get the NHibernate session > var session = > NHibernateSessionManager.SessionFactory.GetCurrentSession(); > > // Get the NHibernate session > var legacySession = > LegacyNHibernateSessionManager.SessionFactory.OpenSession(); > var tx = legacySession.BeginTransaction(); > > var tickets = legacySession.CreateCriteria(typeof > (Ticket)).List<Ticket>(); > > foreach (var ticket in tickets) > { > ticket.Id = 0; > foreach (var ticketComment in ticket.Comments) > ticketComment.Id = 0; > > session.Save(ticket); > } > > tx.Commit(); > legacySession.Close(); > > But when I run it I get: > > Illegal attempt to associate a collection with two open sessions > > Which would seem to indicate that what I'm trying to do is illegal... > > Is there a SIMPLE way to do this, or am I going to have to build a new > Ticket entity via code for each one and save that copy instead? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" 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/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
