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
-~----------~----~----~----~------~----~------~--~---

Reply via email to