I'm not really looking to modify NHibernate code to get this working... As I stated, this is just for porting legacy data over basically. And S#arp Architecture is a little more than I'm looking for. I see what you mean about not being able to bind multiple sessions to a context though...
The way I'm using this is dirt simple. Get the objects with one session, and save them with another. What I've done right now, which has gotten me a little further, is to open the legacy session, and pull the objects, then close that session, and open a new session for saving the objects back. This has gotten me dramatically closer to what I need, but I'm still missing something. I'm getting this error instead now: Don't change the reference to a collection with cascade="all-delete- orphan" Any ideas for that one? == What I CAN do, and this does work, is reconstruct all of my objects from scratch and copy the data and then save the new, unassociated object. This means I have to (by hand) map up all of the variables to the data in the old object.. which is easy on my CURRENT objects... but there are two particularly HUGE ones that I am NOT looking forward to (Upwards of a hundred variables each). On Aug 19, 6:48 pm, "David R. Longnecker" <[email protected]> wrote: > 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 herehttp://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 -~----------~----~----~----~------~----~------~--~---
