From 9aa0302e5b05f056a9378c3b0fd02c4b021ca9e2 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 17 Jul 2008 18:53:38 +0000 Subject: [PATCH] early remove calls --- .../Data/NHibernate/NHibernateRegionData.cs | 45 ++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs index 1f997e7d1a..8ca0afe98c 100644 --- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs +++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs @@ -120,21 +120,45 @@ namespace OpenSim.Data.NHibernate /// the region UUID public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) { - foreach (SceneObjectPart part in obj.Children.Values) + try { - try + foreach (SceneObjectPart part in obj.Children.Values) { m_log.InfoFormat("Storing part {0}", part.UUID); session.SaveOrUpdate(part); - session.Flush(); - } - catch (Exception e) - { - m_log.Error("Can't save: ", e); } + session.Flush(); + } + catch (Exception e) + { + m_log.Error("Can't save: ", e); + } + } + private SceneObjectGroup LoadObject(LLUUID uuid, LLUUID region) + { + SceneObjectGroup group = new SceneObjectGroup(); + + ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart)); + criteria.Add(Expression.Eq("RegionID", region)); + criteria.Add(Expression.Eq("ParentUUID", uuid)); + criteria.AddOrder( Order.Asc("ParentID") ); + + foreach (SceneObjectPart p in criteria.List()) + { + // root part + if (p.UUID == uuid) + { + group.AddPart(p); + group.RootPart = p; + } + else + { + group.AddPart(p); + } } + return group; } /// @@ -144,6 +168,13 @@ namespace OpenSim.Data.NHibernate /// the region UUID public void RemoveObject(LLUUID obj, LLUUID regionUUID) { + SceneObjectGroup g = LoadObject(obj, regionUUID); + foreach (SceneObjectPart p in g.Children.Values) + { + session.Delete(p); + } + session.Flush(); + m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); }